use of org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl in project scout.rt by eclipse.
the class JsonFormTableControlTest method testLazyLoadingForm_onUiSelectionChanged.
@Test
public void testLazyLoadingForm_onUiSelectionChanged() throws Exception {
FormWithOneField form = new FormWithOneField();
FormTableControl control = new FormTableControl();
control.setTable(new Table());
control.setForm(form);
control.decorateForm();
JsonTableControl<ITableControl> jsonControl = UiSessionTestUtility.newJsonAdapter(m_uiSession, control, null);
assertNull(jsonControl.getAdapter(form));
JsonEvent event = createJsonSelectedEvent(jsonControl.getId(), true);
jsonControl.handleUiEvent(event);
// Form needs to be created and sent if selection changes to true
IJsonAdapter<?> formAdapter = jsonControl.getAdapter(form);
assertNotNull(formAdapter);
String formId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonControl.getId(), "form");
assertEquals(formAdapter.getId(), formId);
JsonTestUtility.endRequest(m_uiSession);
// Don't send form again on subsequent selection changes
event = createJsonSelectedEvent(jsonControl.getId(), false);
jsonControl.handleUiEvent(event);
formId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonControl.getId(), "form");
assertNull(formId);
JsonTestUtility.endRequest(m_uiSession);
event = createJsonSelectedEvent(jsonControl.getId(), true);
jsonControl.handleUiEvent(event);
formId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonControl.getId(), "form");
assertNull(formId);
}
Aggregations