Search in sources :

Example 16 with WebFormComponent

use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.

the class FoundsetTest method foundsetViewportBounds.

@Test
public void foundsetViewportBounds() throws JSONException {
    IWebFormController form = (IWebFormController) client.getFormManager().showFormInCurrentContainer("test");
    Assert.assertNotNull(form);
    WebFormComponent wc = form.getFormUI().getWebComponent("mycustombean");
    FoundsetTypeSabloValue rawPropertyValue = (FoundsetTypeSabloValue) wc.getRawPropertyValue("myfoundset");
    BrowserConverterContext allowBrowserConverterContext = new BrowserConverterContext(wc, PushToServerEnum.allow);
    FoundsetTypeViewport viewPort = rawPropertyValue.getViewPort();
    viewPort.setBounds(0, 2);
    StringWriter stringWriter = new StringWriter();
    JSONWriter jsonWriter = new JSONWriter(stringWriter);
    rawPropertyValue.toJSON(jsonWriter, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"serverSize\":18,\"foundsetId\":2,\"sortColumns\":\"\",\"selectedRowIndexes\":[0],\"multiSelect\":false,\"hasMoreRows\":false,\"viewPort\":{\"startIndex\":0,\"size\":2,\"rows\":[{\"_svyRowId\":\"1.1;_0\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.2;_1\",\"lastname\":\"value4\",\"firstname\":\"value3\"}]}}").similar(new JSONObject(stringWriter.toString())));
    try {
        rawPropertyValue.getFoundset().setSort("test1 asc");
    } catch (ServoyException e) {
        e.printStackTrace();
    }
    stringWriter = new StringWriter();
    jsonWriter = new JSONWriter(stringWriter);
    rawPropertyValue.toJSON(jsonWriter, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"serverSize\":18,\"foundsetId\":2,\"sortColumns\":\"firstname asc\",\"selectedRowIndexes\":[0],\"multiSelect\":false,\"hasMoreRows\":false,\"viewPort\":{\"startIndex\":0,\"size\":2,\"rows\":[{\"_svyRowId\":\"1.1;_0\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.2;_1\",\"lastname\":\"value4\",\"firstname\":\"value3\"}]}}").similar(new JSONObject(stringWriter.toString())));
    try {
        rawPropertyValue.getFoundset().setSort("test2 desc,pk asc,test1 asc");
    } catch (ServoyException e) {
        e.printStackTrace();
    }
    stringWriter = new StringWriter();
    jsonWriter = new JSONWriter(stringWriter);
    rawPropertyValue.toJSON(jsonWriter, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"serverSize\":18,\"foundsetId\":2,\"sortColumns\":\"lastname desc\",\"selectedRowIndexes\":[0],\"multiSelect\":false,\"hasMoreRows\":false,\"viewPort\":{\"startIndex\":0,\"size\":2,\"rows\":[{\"_svyRowId\":\"1.1;_0\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.2;_1\",\"lastname\":\"value4\",\"firstname\":\"value3\"}]}}").similar(new JSONObject(stringWriter.toString())));
    try {
        rawPropertyValue.getFoundset().setSort("test2 desc,test1 asc");
    } catch (ServoyException e) {
        e.printStackTrace();
    }
    stringWriter = new StringWriter();
    jsonWriter = new JSONWriter(stringWriter);
    rawPropertyValue.toJSON(jsonWriter, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"serverSize\":18,\"foundsetId\":2,\"sortColumns\":\"lastname desc,firstname asc\",\"selectedRowIndexes\":[0],\"multiSelect\":false,\"hasMoreRows\":false,\"viewPort\":{\"startIndex\":0,\"size\":2,\"rows\":[{\"_svyRowId\":\"1.1;_0\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.2;_1\",\"lastname\":\"value4\",\"firstname\":\"value3\"}]}}").similar(new JSONObject(stringWriter.toString())));
    try {
        rawPropertyValue.getFoundset().setSort("pk asc,test1 asc");
    } catch (ServoyException e) {
        e.printStackTrace();
    }
    stringWriter = new StringWriter();
    jsonWriter = new JSONWriter(stringWriter);
    rawPropertyValue.toJSON(jsonWriter, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"serverSize\":18,\"foundsetId\":2,\"sortColumns\":\"\",\"selectedRowIndexes\":[0],\"multiSelect\":false,\"hasMoreRows\":false,\"viewPort\":{\"startIndex\":0,\"size\":2,\"rows\":[{\"_svyRowId\":\"1.1;_0\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.2;_1\",\"lastname\":\"value4\",\"firstname\":\"value3\"}]}}").similar(new JSONObject(stringWriter.toString())));
    // changes to json
    // add changes test
    viewPort.setBounds(1, 1);
    StringWriter stringWriter2 = new StringWriter();
    JSONWriter jsonWriter2 = new JSONWriter(stringWriter2);
    rawPropertyValue.toJSON(jsonWriter2, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"serverSize\":18,\"foundsetId\":2,\"sortColumns\":\"\",\"selectedRowIndexes\":[0],\"multiSelect\":false,\"hasMoreRows\":false,\"viewPort\":{\"startIndex\":1,\"size\":1,\"rows\":[{\"_svyRowId\":\"1.2;_1\",\"lastname\":\"value4\",\"firstname\":\"value3\"}]}}").similar(new JSONObject(stringWriter2.toString())));
    viewPort.loadExtraRecords(-1);
    StringWriter stringWriter3 = new StringWriter();
    JSONWriter jsonWriter3 = new JSONWriter(stringWriter3);
    rawPropertyValue.changesToJSON(jsonWriter3, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"upd_viewPort\":{\"startIndex\":0,\"size\":2,\"upd_rows\":[{\"rows\":[{\"_svyRowId\":\"1.1;_0\",\"lastname\":\"value2\",\"firstname\":\"value1\"}],\"startIndex\":0,\"endIndex\":0,\"type\":1}]}}").similar(new JSONObject(stringWriter3.toString())));
    viewPort.loadExtraRecords(-1);
    stringWriter3 = new StringWriter();
    jsonWriter3 = new JSONWriter(stringWriter3);
    rawPropertyValue.changesToJSON(jsonWriter3, new DataConversion(), allowBrowserConverterContext);
    Assert.assertEquals(new JSONObject("{\"n\":true}").toString(), new JSONObject(stringWriter3.toString()).toString());
    viewPort.loadExtraRecords(16);
    stringWriter3 = new StringWriter();
    jsonWriter3 = new JSONWriter(stringWriter3);
    rawPropertyValue.changesToJSON(jsonWriter3, new DataConversion(), allowBrowserConverterContext);
    Assert.assertTrue(new JSONObject("{\"upd_viewPort\":{\"startIndex\":0,\"size\":18,\"upd_rows\":[{\"rows\":[{\"_svyRowId\":\"1.3;_2\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.4;_3\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"1.5;_4\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.6;_5\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"1.7;_6\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"1.8;_7\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"1.9;_8\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"2.10;_9\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"2.11;_10\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"2.12;_11\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"2.13;_12\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"2.14;_13\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"2.15;_14\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"2.16;_15\",\"lastname\":\"value4\",\"firstname\":\"value3\"},{\"_svyRowId\":\"2.17;_16\",\"lastname\":\"value2\",\"firstname\":\"value1\"},{\"_svyRowId\":\"2.18;_17\",\"lastname\":\"value4\",\"firstname\":\"value3\"}],\"startIndex\":2,\"endIndex\":17,\"type\":1}]}}").similar(new JSONObject(stringWriter3.toString())));
    viewPort.loadExtraRecords(1);
    stringWriter3 = new StringWriter();
    jsonWriter3 = new JSONWriter(stringWriter3);
    rawPropertyValue.changesToJSON(jsonWriter3, new DataConversion(), allowBrowserConverterContext);
    Assert.assertEquals("{\"n\":true}", stringWriter3.toString());
}
Also used : JSONWriter(org.json.JSONWriter) DataConversion(org.sablo.websocket.utils.DataConversion) StringWriter(java.io.StringWriter) JSONObject(org.json.JSONObject) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) WebFormComponent(com.servoy.j2db.server.ngclient.WebFormComponent) BrowserConverterContext(org.sablo.specification.property.BrowserConverterContext) IWebFormController(com.servoy.j2db.server.ngclient.IWebFormController) ServoyException(com.servoy.j2db.util.ServoyException) Test(org.junit.Test)

Example 17 with WebFormComponent

use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.

the class FoundsetTest method foundsetWithDynamicDataproviders.

@Test
public void foundsetWithDynamicDataproviders() throws JSONException {
    IWebFormController form = (IWebFormController) client.getFormManager().showFormInCurrentContainer("test");
    WebFormComponent webComponent = form.getFormUI().getWebComponent("mydynamiccustombean");
    FoundsetTypeSabloValue property = (FoundsetTypeSabloValue) webComponent.getProperty("myfoundset");
    JSONArray json = new JSONArray("[{" + FoundsetTypeSabloValue.PREFERRED_VIEWPORT_SIZE + ":1}]");
    property.browserUpdatesReceived(json, webComponent.getSpecification().getProperty("myfoundset"), new BrowserConverterContext(webComponent, PushToServerEnum.allow));
    Assert.assertNotNull(form);
    String full = NGUtils.formComponentPropertiesToString(form.getFormUI(), FullValueToJSONConverter.INSTANCE);
    JSONObject object = new JSONObject(full);
    JSONObject bean = object.getJSONObject("mydynamiccustombean");
    JSONObject foundset = bean.getJSONObject("myfoundset");
    Assert.assertEquals(12, foundset.getInt("serverSize"));
    JSONObject viewPort = foundset.getJSONObject("viewPort");
    Assert.assertEquals(0, viewPort.getInt("startIndex"));
    Assert.assertEquals(12, viewPort.getInt("size"));
    Assert.assertEquals(12, viewPort.getJSONArray("rows").length());
    // fake incomming request for view port change.
    endpoint.incoming("{\"methodname\":\"dataPush\",\"args\":{\"beanname\":\"mydynamiccustombean\",\"formname\":\"test\",\"changes\":{\"myfoundset\":[{\"newViewPort\":{\"startIndex\":0,\"size\":3}, \"id\": 4312}]}},\"service\":\"formService\"}", true);
    String changes = NGUtils.formChangesToString(((Container) form.getFormUI()), FullValueToJSONConverter.INSTANCE);
    object = new JSONObject(changes).getJSONObject("changes");
    bean = object.getJSONObject("mydynamiccustombean");
    foundset = bean.getJSONObject("myfoundset");
    Assert.assertEquals(12, foundset.getInt("serverSize"));
    viewPort = foundset.getJSONObject("viewPort");
    Assert.assertEquals(0, viewPort.getInt("startIndex"));
    Assert.assertEquals(3, viewPort.getInt("size"));
    JSONArray rows = viewPort.getJSONArray("rows");
    Assert.assertEquals(3, rows.length());
    JSONArray handledClientReqIds = foundset.getJSONArray("handledClientReqIds");
    Assert.assertEquals(1, handledClientReqIds.length());
    Assert.assertEquals(4312, handledClientReqIds.getJSONObject(0).getInt("id"));
    Assert.assertTrue(handledClientReqIds.getJSONObject(0).getBoolean("value"));
    JSONObject row0 = rows.getJSONObject(0);
    Assert.assertEquals("relatedvalue111", row0.getString("dp1"));
    Assert.assertEquals("relatedvalue112", row0.getString("dp2"));
    JSONObject row1 = rows.getJSONObject(1);
    Assert.assertEquals("relatedvalue121", row1.getString("dp1"));
    Assert.assertEquals("relatedvalue122", row1.getString("dp2"));
}
Also used : Container(org.sablo.Container) JSONObject(org.json.JSONObject) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) WebFormComponent(com.servoy.j2db.server.ngclient.WebFormComponent) JSONArray(org.json.JSONArray) BrowserConverterContext(org.sablo.specification.property.BrowserConverterContext) IWebFormController(com.servoy.j2db.server.ngclient.IWebFormController) Test(org.junit.Test)

Example 18 with WebFormComponent

use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.

the class PersistFieldInstanceTest method testCustomComponentWithFormProperty.

@Test
public void testCustomComponentWithFormProperty() throws RepositoryException, JSONException {
    // TODO this should become a test on form uuid in the inner html/bean xml instead of the form name..
    Form form = solution.getForm("test");
    Assert.assertNotNull(form);
    DataAdapterList dataAdapterList = new DataAdapterList(new TestFormController(form, client));
    Form tabForm = solution.createNewForm(validator, null, "tabform", null, false, new Dimension(600, 400));
    // as client's "inDesigner" == true we will generate an error bean because legacy Bean usage for custom web components with custom object/array types is depreacated and not fully working (in designer at least)
    // so we will check that it generates an error bean (that means no props are set)
    // TODO maybe this can be uncommented after https://support.servoy.com/browse/SVY-9459 is done
    // Bean bean = form.createNewBean("mycustombean", "my-component");
    // bean.setInnerHTML("{atype:{name:'name',form:'tabform'}}");
    List<FormElement> formElements = FormElementHelper.INSTANCE.getFormElements(form.getAllObjects(), new ServoyDataConverterContext(client));
    // Assert.assertEquals(1, formElements.size());
    // WebFormComponent wc = ComponentFactory.createComponent(client, dataAdapterList, formElements.get(0), null);
    @SuppressWarnings("unchecked") WebComponent // form.removeChild(bean);
    webComponent = form.createNewWebComponent("mycustombean", "my-component");
    webComponent.setProperty("atype", new ServoyJSONObject("{name:'name',form:'tabform'}", false));
    formElements = FormElementHelper.INSTANCE.getFormElements(form.getAllObjects(), new ServoyDataConverterContext(client));
    Assert.assertEquals(1, formElements.size());
    WebFormComponent wc = ComponentFactory.createComponent(client, dataAdapterList, formElements.get(0), null, form);
    Map<String, Object> type = (Map<String, Object>) wc.getProperty("atype");
    Assert.assertEquals("name", type.get("name"));
    Assert.assertEquals("tabform", type.get("form"));
    Assert.assertEquals(0, wc.getAndClearChanges().content.size());
    TypedData<Map<String, Object>> props = wc.getProperties();
    String json = JSONUtils.writeDataWithConversions(props.content, props.contentType, null);
    JSONAssert.assertEquals("{\"atype\":{\"rt\":\"my-component.mytype\",\"vEr\":2,\"v\":{\"form\":\"tabform\",\"name\":\"name\"}},\"svyMarkupId\":\"sf331d64ddc0c17747371b7740e3e3447\",\"svy_types\":{\"atype\":\"JSON_obj\"}}", json, true);
}
Also used : Form(com.servoy.j2db.persistence.Form) WebFormComponent(com.servoy.j2db.server.ngclient.WebFormComponent) IDataAdapterList(com.servoy.j2db.server.ngclient.IDataAdapterList) DataAdapterList(com.servoy.j2db.server.ngclient.DataAdapterList) Dimension(java.awt.Dimension) FormElement(com.servoy.j2db.server.ngclient.FormElement) WebComponent(com.servoy.j2db.persistence.WebComponent) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) ServoyDataConverterContext(com.servoy.j2db.server.ngclient.ServoyDataConverterContext) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 19 with WebFormComponent

use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.

the class PersistFieldInstanceTest method testCustomComponentWithI18NProperty.

@Test
public void testCustomComponentWithI18NProperty() throws RepositoryException, JSONException {
    Form form = solution.getForm("test");
    Assert.assertNotNull(form);
    DataAdapterList dataAdapterList = new DataAdapterList(new TestFormController(form, client));
    WebComponent bean = form.createNewWebComponent("mycustombean", "my-component");
    bean.setProperty("atype", new ServoyJSONObject("{name:'name',text:'i18n:servoy.button.ok'}", false));
    List<FormElement> formElements = FormElementHelper.INSTANCE.getFormElements(form.getAllObjects(), new ServoyDataConverterContext(client));
    Assert.assertEquals(1, formElements.size());
    WebFormComponent wc = ComponentFactory.createComponent(client, dataAdapterList, formElements.get(0), null, form);
    BrowserConverterContext allowBrowserConverterContext = new BrowserConverterContext(wc, PushToServerEnum.allow);
    Map<String, Object> type = (Map<String, Object>) wc.getProperty("atype");
    Assert.assertEquals("name", type.get("name"));
    // it gets automatically translated to a static string
    Assert.assertEquals("OK", ((BasicTagStringTypeSabloValue) type.get("text")).getDesignValue());
    Assert.assertEquals("OK", ((BasicTagStringTypeSabloValue) type.get("text")).getTagReplacedValue());
    Assert.assertEquals(0, wc.getAndClearChanges().content.size());
    TypedData<Map<String, Object>> props = wc.getProperties();
    String json = JSONUtils.writeDataWithConversions(props.content, props.contentType, allowBrowserConverterContext);
    JSONAssert.assertEquals("{\"atype\":{\"rt\":\"my-component.mytype\",\"vEr\":2,\"v\":{\"text\":\"OK\",\"name\":\"name\"}},\"svyMarkupId\":\"sf331d64ddc0c17747371b7740e3e3447\",\"svy_types\":{\"atype\":\"JSON_obj\"}}", json, true);
}
Also used : Form(com.servoy.j2db.persistence.Form) WebFormComponent(com.servoy.j2db.server.ngclient.WebFormComponent) IDataAdapterList(com.servoy.j2db.server.ngclient.IDataAdapterList) DataAdapterList(com.servoy.j2db.server.ngclient.DataAdapterList) FormElement(com.servoy.j2db.server.ngclient.FormElement) WebComponent(com.servoy.j2db.persistence.WebComponent) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) ServoyDataConverterContext(com.servoy.j2db.server.ngclient.ServoyDataConverterContext) BrowserConverterContext(org.sablo.specification.property.BrowserConverterContext) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 20 with WebFormComponent

use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.

the class TabPanelTest method testRelatedFormsInTabPanels.

@SuppressWarnings("nls")
@Test
public void testRelatedFormsInTabPanels() throws JSONException {
    IWebFormController form = (IWebFormController) client.getFormManager().showFormInCurrentContainer("f1");
    WebFormComponent webComponent = form.getFormUI().getWebComponent("tabpanel");
    Object property = webComponent.getProperty("tabIndex");
    Assert.assertEquals(((Number) property).longValue(), 1);
    StringWriter stringWriter = new StringWriter();
    JSONWriter jsonWriter = new JSONWriter(stringWriter);
    jsonWriter.object();
    form.getFormUI().writeAllComponentsProperties(jsonWriter, FullValueToJSONConverter.INSTANCE);
    jsonWriter.endObject();
    JSONAssert.assertEquals("{\"\":{\"enabled\":true,\"visible\":true,\"findmode\":false},\"tabpanel\":{\"enabled\":true,\"svyMarkupId\":\"s554517c05b68828168c38c67974bf993\",\"tabs\":{\"vEr\":3,\"w\":false,\"v\":[{\"rt\":\"servoydefault-tabpanel.tab\",\"vEr\":3,\"w\":false,\"v\":{\"relationName\":\"-1\",\"text\":\"tab1\",\"active\":true,\"containsFormId\":\"f2\",\"disabled\":false}},{\"rt\":\"servoydefault-tabpanel.tab\",\"vEr\":3,\"w\":false,\"v\":{\"relationName\":\"-1\",\"text\":\"tab2\",\"active\":false,\"containsFormId\":\"f3\",\"disabled\":false}},{\"rt\":\"servoydefault-tabpanel.tab\",\"vEr\":3,\"w\":false,\"v\":{\"relationName\":\"-1\",\"text\":\"tab3\",\"active\":false,\"containsFormId\":\"f4\",\"disabled\":false}}],\"svy_types\":{\"2\":\"JSON_obj\",\"1\":\"JSON_obj\",\"0\":\"JSON_obj\"}}},\"svy_types\":{\"tabpanel\":{\"tabs\":\"JSON_arr\"}}}", stringWriter.toString(), true);
    webComponent.setProperty("tabIndex", "tab2");
    stringWriter = new StringWriter();
    jsonWriter = new JSONWriter(stringWriter);
    jsonWriter.object();
    form.getFormUI().writeAllComponentsProperties(jsonWriter, FullValueToJSONConverter.INSTANCE);
    jsonWriter.endObject();
    System.err.println(stringWriter.toString());
    JSONAssert.assertEquals("{\"\":{\"enabled\":true,\"visible\":true,\"findmode\":false},\"tabpanel\":{\"enabled\":true,\"svyMarkupId\":\"s554517c05b68828168c38c67974bf993\",\"tabIndex\":\"tab2\",\"tabs\":{\"vEr\":4,\"w\":false,\"v\":[{\"rt\":\"servoydefault-tabpanel.tab\",\"vEr\":4,\"w\":false,\"v\":{\"relationName\":\"-1\",\"text\":\"tab1\",\"active\":true,\"containsFormId\":\"f2\",\"disabled\":false}},{\"rt\":\"servoydefault-tabpanel.tab\",\"vEr\":4,\"w\":false,\"v\":{\"relationName\":\"-1\",\"text\":\"tab2\",\"active\":false,\"containsFormId\":\"f3\",\"disabled\":false}},{\"rt\":\"servoydefault-tabpanel.tab\",\"vEr\":4,\"w\":false,\"v\":{\"relationName\":\"-1\",\"text\":\"tab3\",\"active\":false,\"containsFormId\":\"f4\",\"disabled\":false}}],\"svy_types\":{\"2\":\"JSON_obj\",\"1\":\"JSON_obj\",\"0\":\"JSON_obj\"}}},\"svy_types\":{\"tabpanel\":{\"tabs\":\"JSON_arr\"}}}", stringWriter.toString(), true);
    webComponent.setProperty("tabIndex", Integer.valueOf(3));
    stringWriter = new StringWriter();
    jsonWriter = new JSONWriter(stringWriter);
    jsonWriter.object();
    form.getFormUI().writeAllComponentsProperties(jsonWriter, FullValueToJSONConverter.INSTANCE);
    jsonWriter.endObject();
    System.err.println(stringWriter.toString());
    JSONAssert.assertEquals("{\"\":{\"enabled\":true,\"visible\":true,\"findmode\":false},\"tabpanel\":{\"enabled\":true,\"svyMarkupId\":\"s554517c05b68828168c38c67974bf993\",\"tabIndex\":3,\"tabs\":{\"vEr\":5,\"w\":false,\"v\":[{\"rt\":\"servoydefault-tabpanel.tab\",\"vEr\":5,\"w\":false,\"v\":{\"relationName\":\"-1\",\"text\":\"tab1\",\"active\":true,\"containsFormId\":\"f2\",\"disabled\":false}},{\"rt\":\"servoydefault-tabpanel.tab\",\"vEr\":5,\"w\":false,\"v\":{\"relationName\":\"-1\",\"text\":\"tab2\",\"active\":false,\"containsFormId\":\"f3\",\"disabled\":false}},{\"rt\":\"servoydefault-tabpanel.tab\",\"vEr\":5,\"w\":false,\"v\":{\"relationName\":\"-1\",\"text\":\"tab3\",\"active\":false,\"containsFormId\":\"f4\",\"disabled\":false}}],\"svy_types\":{\"2\":\"JSON_obj\",\"1\":\"JSON_obj\",\"0\":\"JSON_obj\"}}},\"svy_types\":{\"tabpanel\":{\"tabs\":\"JSON_arr\"}}}", stringWriter.toString(), true);
}
Also used : JSONWriter(org.json.JSONWriter) StringWriter(java.io.StringWriter) WebFormComponent(com.servoy.j2db.server.ngclient.WebFormComponent) IWebFormController(com.servoy.j2db.server.ngclient.IWebFormController) Test(org.junit.Test)

Aggregations

WebFormComponent (com.servoy.j2db.server.ngclient.WebFormComponent)31 Test (org.junit.Test)14 Form (com.servoy.j2db.persistence.Form)12 FormElement (com.servoy.j2db.server.ngclient.FormElement)10 IWebFormController (com.servoy.j2db.server.ngclient.IWebFormController)10 ServoyJSONObject (com.servoy.j2db.util.ServoyJSONObject)10 JSONObject (org.json.JSONObject)10 BrowserConverterContext (org.sablo.specification.property.BrowserConverterContext)10 StringWriter (java.io.StringWriter)7 JSONWriter (org.json.JSONWriter)7 DataConversion (org.sablo.websocket.utils.DataConversion)7 IDataAdapterList (com.servoy.j2db.server.ngclient.IDataAdapterList)6 Point (java.awt.Point)6 DataAdapterList (com.servoy.j2db.server.ngclient.DataAdapterList)5 ServoyDataConverterContext (com.servoy.j2db.server.ngclient.ServoyDataConverterContext)5 Map (java.util.Map)5 IContextProvider (com.servoy.j2db.server.ngclient.IContextProvider)4 IWebFormUI (com.servoy.j2db.server.ngclient.IWebFormUI)4 HashMap (java.util.HashMap)4 FlattenedSolution (com.servoy.j2db.FlattenedSolution)3