Class A{ private void init() { MARList marList = new MARList(); RecordClickHandler marClickHandler = new RecordClickHandler() { public void onRecordClick(RecordClickEvent event) { openMAR(event.getRecord().getAttribute("id"), backButtonClickHandler); } }; marList.addMarRecordClickHandler(marClickHandler); } public void openMAR(String id, MarBackClickHandler backButtonClickHandler) { listLayout.setVisible(false); editLayout.setVisible(true); classB.openMAR(id); classB.getTopMenu().addBackButtonHandler(backButtonClickHandler); } } class B{ private void init() { prepareMarDetailsForm(); } public void openMAR(String id) { topMenu.resetAllWorkFlowActions(); validO2ETask = true; validO2KWorkOrderNumber=true; this.id = id; fetch(); detailLayout.scrollToTop(); } private void prepareMarDetailsForm() { SectionStackSection section1 = new SectionStackSection(); section1.setExpanded(true); section1.setCanCollapse(false); section1.setShowHeader(false); //First form form1 = new DynamicForm(); form1.setWrapItemTitles(false); form1.setCellPadding(5); form1.setNumCols(6); HiddenItem id = new HiddenItem("id"); HiddenItem hiddenItem1 = new HiddenItem("hiddenItem1"); HiddenItem hiddenItem2 = new HiddenItem("hiddenItem2"); HiddenItem hiddenItem3 = new HiddenItem("hiddenItem3"); HiddenItem hiddenItem4 = new HiddenItem("hiddenItem4"); HiddenItem hiddenItem5 = new HiddenItem("hiddenItem5"); HiddenItem hiddenItem6 = new HiddenItem("hiddenItem6"); HiddenItem hiddenItem7 = new HiddenItem("hiddenItem7"); HiddenItem hiddenItem8 = new HiddenItem("hiddenItem8"); HiddenItem hiddenItem9 = new HiddenItem("hiddenItem9"); HiddenItem hiddenItem10 = new HiddenItem("hiddenItem10"); if(userRole){ hiddenItem10.setValue("true"); } else{ hiddenItem10.setValue("false"); } final StaticTextItem textItem1 = new StaticTextItem("textItem1", "Text Item 1"); textItem1.setWrap(false); textItem1.setCanEdit(false); final OurDateItem dateItem1 = new OurDateItem("dateItem1", "Date Item 1"); dateItem1.setUseTextField(true); dateItem1.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { Date newDate = dateItem1.getValueAsDate(); if ((newDate == null && currentRecord.getAttributeAsDate("dateItem1") == null) || DateUtil.compareLogicalDates(currentRecord.getAttributeAsDate("dateItem1"), newDate)==0) { form1.getField("hiddenItem2").setValue(new Boolean(false)); if (currentRecord.getAttributeAsBoolean("hiddenItem2")) { if (currentRecord.getAttributeAsBoolean("hiddenItem3")) { event.getItem().setHint("(Date) (Edited)"); } else { event.getItem().setHint("(Edited)"); } } else { if (currentRecord.getAttributeAsBoolean("hiddenItem3")) { event.getItem().setHint("(Date)"); } else { event.getItem().setHint(""); } } } else { form1.getField("hiddenItem2").setValue(new Boolean(true)); if (newDate!=null && DateUtil.compareLogicalDates(new Date(), newDate) < 0) { event.getItem().setHint("(Date) (Edited)"); } else { event.getItem().setHint("(Edited)"); } } } }); StaticTextItem textItem2 = new StaticTextItem("textItem2", "Text Item 2"); FormItemIcon itemIcon1 = new FormItemIcon(); itemIcon1.setSrc(ApplicationImageConstant.EDIT); itemIcon1.addFormItemClickHandler(new FormItemClickHandler() { @Override public void onFormItemClick(FormItemIconClickEvent event) { // TODO Auto-generated method stub surveyTableWin = new SurveyTableWindow(true,facilityTypeId,certificateId); surveyTableWin.show(); } }); textItem2.setIcons(itemIcon1); StaticTextItem textItem3 = new StaticTextItem("textItem3", "Text Item 3"); ComboBoxItem comboItem1 = new ComboBoxItem("comboItem1", "ComboBox Item 1"); comboItem1.setValueMap("Please Select","30","60","90"); comboItem1.setDefaultToFirstOption(true); comboItem1.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { save(new DSCallback() { @Override public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) { fetch(); } }); } }); ComboBoxItem comboItem2 = new ComboBoxItem ("comboItem2", "ComboBox Item 2"); comboItem2.setAddUnknownValues(false); Criteria criteria = new Criteria("lookupType", ILookupTypes.Item_lookup); comboItem2.setOptionCriteria(criteria); comboItem2.setValidators(new CustomValidator() { @Override protected boolean condition(Object value) { if (form1.getField("comboItem2").isVisible()) { if (form1.getField("comboItem2").getValue() == null) { setErrorMessage("Please select from comboItem2"); return false; } } return true; } }); StaticTextItem textItem4 = new StaticTextItem("textItem4", "Text Item 4"); HiddenItem hiddenItem11 = new HiddenItem("hiddenItem11"); StaticTextItem textItem5 = new StaticTextItem("textItem5", "Text Item 5"); HiddenItem hiddenItem12 = new HiddenItem("hiddenItem12"); HiddenItem hiddenItem13 = new HiddenItem("hiddenItem13"); HiddenItem hiddenItem14 = new HiddenItem("hiddenItem14"); StaticTextItem textItem6 = new StaticTextItem("textItem6", "Text Item 6"); HiddenItem hiddenItem15 = new HiddenItem("hiddenItem15"); StaticTextItem textItem7 = new StaticTextItem("textItem7"); if (!isWindow) { textItem7.setTextBoxStyle("linkItem"); } textItem7.setTitleVAlign(VerticalAlignment.TOP); textItem7.setIconVAlign(VerticalAlignment.TOP); textItem7.setValidators(new CustomValidator() { @Override protected boolean condition(Object value) { setErrorMessage("textItem7 not selected."); if (form1.getField("item16").getValue() !=null) { return true; } return false; } }); textItem7.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { @Override public void onClick( com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { if (form1.getField("item16").getValue()!=null) { CompanyInformationPane companyInfoPane = (CompanyInformationPane)GlobalTabSet.getInstance().getTab(GlobalTabSet.COMPANY_INFO_TAB_ID).getPane(); companyInfoPane.openCompany(form1.getField("item16").getValue().toString(), form1.getField("company").getValue().toString()); GlobalTabSet.getInstance().selectTab(GlobalTabSet.COMPANY_INFO_TAB_ID); } } }); HiddenItem item16 = new HiddenItem("item16"); textItem3.setWrap(false); textItem4.setWrap(false); form1.setFields(id,hiddenItem7,hiddenItem9,hiddenItem14,hiddenItem13,hiddenItem1 ,hiddenItem2,textItem1,dateItem1,hiddenItem6,textItem2,textItem7 ,item16,hiddenItem4,comboItem1,textItem3,comboItem2,textItem4 ,hiddenItem11,textItem5,hiddenItem12,textItem6,hiddenItem15,hiddenItem5,hiddenItem8,hiddenItem3,hiddenItem10); form1.setValuesManager(valueManager); section1.addItem(form1); LayoutSpacer spacer1 = new LayoutSpacer(); spacer1.setHeight(15); section1.addItem(spacer1); detailStack.addSection(section1); //Second form SectionStackSection section2 = new SectionStackSection(); section2.setTitle("Information"); section2.setExpanded(true); form2 = new DynamicForm(); form2.setWrapItemTitles(false); form2.setCellPadding(5); form2.setNumCols(6); final TextItem textItem12 = new TextItem("textItem12", "Text Item 12"); textItem12.setBrowserSpellCheck(true); FormItemHelpIcon textItem12HelpIcon = new FormItemHelpIcon("textItem12"); textItem12.setValidators(new CustomValidator() { @Override protected boolean condition(Object value) { this.setErrorMessage("Invalid task number"); return validO2ETask; } }); textItem12.addEditorExitHandler(new EditorExitHandler() { @Override public void onEditorExit(EditorExitEvent event) { if (event.getValue()==null) { validO2ETask = false; resetDataFromTask(); form1.getField("textItem1").setValue(""); form1.getField("textItem1").setHint("Enter task to generate Number."); } else { final String taskInput = event.getValue().toString().trim(); ClientCache.getManufacturerApprovalRequestService().validateTaskNumber(taskInput,certIdString, new AsyncCallback() { @Override public void onSuccess(O2ETaskNumber result) { if (result == null || result.getTaskId() == null) { validO2ETask = false; textItem12.validate(); resetDataFromTask(); form1.getField("textItem1").setValue(""); form1.getField("textItem1").setHint("Enter task to generate Number."); } else { validO2ETask = true; textItem12.validate(); populateDataFromTask(result); } } @Override public void onFailure(Throwable caught) { validO2ETask = false; textItem12.validate(); resetDataFromTask(); SC.warn("Error", caught.getMessage()); } }); } } }); final TextItem textItem13 = new TextItem("textItem13", "Text Item 13"); textItem12.setBrowserSpellCheck(true); FormItemHelpIcon textItem13HelpIcon = new FormItemHelpIcon("textItem13"); textItem13.setKeyPressFilter("[0-9]"); textItem13.setValidators(new CustomValidator() { @Override protected boolean condition(Object value) { this.setErrorMessage("Invalid work order number"); return validO2KWorkOrderNumber; } }); textItem13.addEditorExitHandler(new EditorExitHandler() { @Override public void onEditorExit(EditorExitEvent event) { if (event.getValue()==null) { validO2KWorkOrderNumber = false; resetDataFromWorkOrder(); } else { final String workOderInput = event.getValue().toString();; ClientCache.getManufacturerApprovalRequestService().validateWONumber(Long.valueOf(workOderInput),certIdString,new AsyncCallback() { @Override public void onSuccess(O2KWorkOrder result) { if (result == null || result.getWorkOrderId() == null) { validO2KWorkOrderNumber = false; textItem13.validate(); resetDataFromWorkOrder(); } else { validO2KWorkOrderNumber = true; textItem13.validate(); populateDataFromWorkOrder(result); } } @Override public void onFailure(Throwable caught) { validO2KWorkOrderNumber = false; textItem13.validate(); resetDataFromWorkOrder(); SC.warn("Error", caught.getMessage()); } }); } } }); StaticTextItem textItem8 = new StaticTextItem("textItem8", "Text Item 8"); FormItemHelpIcon textItem8HelpIcon = new FormItemHelpIcon("textItem8"); textItem8.setWrap(false); StaticTextItem textItem9 = new StaticTextItem("textItem9", "Text Item 9"); FormItemHelpIcon textItem9HelpIcon = new FormItemHelpIcon("textItem9"); textItem9.setWrap(false); StaticTextItem textItem10 = new StaticTextItem("textItem10", "Text Item 10"); FormItemHelpIcon textItem10HelpIcon = new FormItemHelpIcon("textItem10"); textItem10.setWrap(false); StaticTextItem textItem11 = new StaticTextItem("textItem11", "Text Item 11"); FormItemHelpIcon textItem11HelpIcon = new FormItemHelpIcon("textItem11"); textItem11.setWrap(false); form2.setFields(textItem12,textItem10,textItem11,textItem13,textItem8,textItem9); form2.setValuesManager(valueManager); section2.addItem(form2); LayoutSpacer spacer2 = new LayoutSpacer(); spacer2.setHeight(15); section2.addItem(spacer2); detailStack.addSection(section2); detailStack.addSection(getProductSection()); detailStack.addSection(getRevisionHistorySection()); detailStack.addSection(getEndorsementHistoryGrid()); detailStack.addSection(getEditHistorySection()); ItemChangeHandler changeHandler = new ItemChangeHandler() { @Override public void onItemChange(ItemChangeEvent event) { isDirty = true; } }; form1.addItemChangeHandler(changeHandler); form2.addItemChangeHandler(changeHandler); } }