Search in sources :

Example 11 with IGroupBox

use of org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox in project scout.rt by eclipse.

the class JsonTabBoxTest method testDontSendNonDisplayableGroups.

/**
 * Tests whether non displayable groups are sent.
 * <p>
 * This reduces response size and also leverages security because the fields are never visible to the user, not even
 * with the dev tools of the browser
 */
@Test
public void testDontSendNonDisplayableGroups() throws Exception {
    ITabBox tabBox = new TabBoxWithNonDisplayableGroup();
    JsonTestUtility.initField(tabBox);
    JsonTabBox<ITabBox> jsonTabBox = UiSessionTestUtility.newJsonAdapter(m_uiSession, tabBox, null);
    JsonGroupBox<IGroupBox> jsonDisplayableGroup = m_uiSession.getJsonAdapter(tabBox.getFieldByClass(TabBoxWithNonDisplayableGroup.DisplayableGroup.class), jsonTabBox);
    JsonGroupBox<IGroupBox> jsonNonDisplayableGroup = m_uiSession.getJsonAdapter(tabBox.getFieldByClass(TabBoxWithNonDisplayableGroup.NonDisplayableGroup.class), jsonTabBox);
    // Adapter for NonDisplayableField must not exist
    assertNull(jsonNonDisplayableGroup);
    // Json response must not contain NonDisplayableField
    JSONObject json = jsonTabBox.toJson();
    JSONArray jsonGroupBoxes = json.getJSONArray("tabItems");
    assertEquals(1, jsonGroupBoxes.length());
    assertEquals(jsonDisplayableGroup.getId(), jsonGroupBoxes.get(0));
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) IGroupBox(org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox) ITabBox(org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox) Test(org.junit.Test)

Example 12 with IGroupBox

use of org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox in project scout.rt by eclipse.

the class AbstractWrappedFormField method acceptVisitor.

@Override
public boolean acceptVisitor(IFormFieldVisitor visitor, int level, int fieldIndex, boolean includeThis) {
    Collection<IFormField> innerFormRootGroupBox = null;
    FORM innerForm = getInnerForm();
    if (innerForm != null) {
        IGroupBox rootGroupBox = innerForm.getRootGroupBox();
        if (rootGroupBox != null) {
            innerFormRootGroupBox = Collections.<IFormField>singletonList(rootGroupBox);
        }
    }
    IFormField thisField = null;
    if (includeThis) {
        thisField = this;
    }
    return CompositeFieldUtility.applyFormFieldVisitor(visitor, thisField, innerFormRootGroupBox, level, fieldIndex);
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) IGroupBox(org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox)

Example 13 with IGroupBox

use of org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox in project scout.rt by eclipse.

the class JsonGroupBoxTest method testDontSendNonDisplayableFields.

/**
 * Tests whether non displayable fields are sent.
 * <p>
 * This reduces response size and also leverages security because the fields are never visible to the user, not even
 * with the dev tools of the browser
 */
@Test
public void testDontSendNonDisplayableFields() throws Exception {
    IGroupBox groupBox = new GroupBoxWithNonDisplayableField();
    JsonTestUtility.initField(groupBox);
    JsonGroupBox<IGroupBox> jsonGroupBox = UiSessionTestUtility.newJsonAdapter(m_uiSession, groupBox, null);
    JsonFormField<IFormField> jsonDisplayableField = m_uiSession.getJsonAdapter(groupBox.getFieldByClass(GroupBoxWithNonDisplayableField.DisplayableField.class), jsonGroupBox);
    JsonFormField<IFormField> jsonNonDisplayableField = m_uiSession.getJsonAdapter(groupBox.getFieldByClass(GroupBoxWithNonDisplayableField.NonDisplayableField.class), jsonGroupBox);
    // Adapter for NonDisplayableField must not exist
    assertNull(jsonNonDisplayableField);
    // Json response must not contain NonDisplayableField
    JSONObject json = jsonGroupBox.toJson();
    JSONArray jsonFormFields = json.getJSONArray("fields");
    assertEquals(1, jsonFormFields.length());
    assertEquals(jsonDisplayableField.getId(), jsonFormFields.get(0));
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) IGroupBox(org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox) Test(org.junit.Test) BaseFormFieldTest(org.eclipse.scout.rt.ui.html.json.form.fields.BaseFormFieldTest)

Aggregations

IGroupBox (org.eclipse.scout.rt.client.ui.form.fields.groupbox.IGroupBox)13 ITabBox (org.eclipse.scout.rt.client.ui.form.fields.tabbox.ITabBox)7 IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)4 IListBox (org.eclipse.scout.rt.client.ui.form.fields.listbox.IListBox)3 ITreeBox (org.eclipse.scout.rt.client.ui.form.fields.treebox.ITreeBox)3 IForm (org.eclipse.scout.rt.client.ui.form.IForm)2 IButton (org.eclipse.scout.rt.client.ui.form.fields.button.IButton)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 Test (org.junit.Test)2 LinkedList (java.util.LinkedList)1 IClientSession (org.eclipse.scout.rt.client.IClientSession)1 MoveFormFieldsHandler (org.eclipse.scout.rt.client.extension.ui.form.MoveFormFieldsHandler)1 IDisplayParent (org.eclipse.scout.rt.client.ui.IDisplayParent)1 IKeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)1 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)1 IViewButton (org.eclipse.scout.rt.client.ui.action.view.IViewButton)1 CalendarComponent (org.eclipse.scout.rt.client.ui.basic.calendar.CalendarComponent)1 ICalendar (org.eclipse.scout.rt.client.ui.basic.calendar.ICalendar)1 IFileChooser (org.eclipse.scout.rt.client.ui.basic.filechooser.IFileChooser)1