I have a two sectionstacksection in code, onw is showing dynamic form for input data and second sectionstacksection is showing listgrid which will show a input data when i hit save button in my dynamic form section.
I have created three classes, one is EmployeeApplicationForm which is extending Dynamic Form, second is EquiryList which is extending listgrid and third one is EnquiryFormRecord which is extending ListGridRecord for getter and setter.
I have done feteching the textboxes data and call a EnquiryFormRecord constructor to get and set datas in "data" Variable. but i am not able to access this "data" variable to my EnquiryList class to "setData(data)" in listGird Field.
My code is this. Please share your idea to resolve this problem EmployeeApplicationClass And EnquiryList:
class EmployeeApplicationForm extends DynamicForm {
ButtonItem saveButton;
ButtonItem resetButton;
EnquiryFormRecord[] data;
public EmployeeApplicationForm() {
setNumCols(6);
setWidth100();
setHeight(135);
setErrorOrientation(FormErrorOrientation.RIGHT);
final TextItem fname = new TextItem("FirstName");
final TextItem lname = new TextItem("LastName");
saveButton = new ButtonItem("Save");
saveButton.setStartRow(true);
saveButton.setEndRow(false);
resetButton = new ButtonItem("Reset");
resetButton.setStartRow(false);
resetButton.setEndRow(false);
saveButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
// if validation passes then show user an alert message box
if (valid()) {
SC.say("Form passed validation");
}
String fn = fname.getValueAsString();
String ln = lname.getValueAsString();
data = new EnquiryFormRecord[] { new EnquiryFormRecord(fn, ln) };
}
});
resetButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
resetForm();
}
});
setFields(fname, lname, saveButton, resetButton);
}
private boolean valid() {
return this.validate();
}
private void resetForm() {
this.reset();
}
}
class EnquiryList extends ListGrid {
public EnquiryList(EnquiryFormRecord[] data) {
ListGridField fname = new ListGridField("fname","First Name");
ListGridField lname = new ListGridField("lname","Last Name");
setFields(fname, lname);
setData(data);------/*Hera I am getting error. I cannot access the EmployeeAppliocationForm class "data" variable here*/
setCanEdit(true);
setShowAllRecords(true);
// setSortField(0);
setAlternateRecordStyles(true);
setCanDragRecordsOut(true);
setHoverWidth(200);
setHoverHeight(20);
setSelectionType(SelectionStyle.SINGLE);
}
}