Search in sources :

Example 6 with FormTableControl

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);
}
Also used : Table(org.eclipse.scout.rt.ui.html.json.table.fixtures.Table) ITableControl(org.eclipse.scout.rt.client.ui.basic.table.controls.ITableControl) JsonEvent(org.eclipse.scout.rt.ui.html.json.JsonEvent) FormTableControl(org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl) FormWithOneField(org.eclipse.scout.rt.ui.html.json.form.fixtures.FormWithOneField) Test(org.junit.Test)

Aggregations

FormTableControl (org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl)6 Test (org.junit.Test)6 ITableControl (org.eclipse.scout.rt.client.ui.basic.table.controls.ITableControl)4 FormWithOneField (org.eclipse.scout.rt.ui.html.json.form.fixtures.FormWithOneField)4 Table (org.eclipse.scout.rt.ui.html.json.table.fixtures.Table)4 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 TableWithoutMenus (org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithoutMenus)2 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)1