Search in sources :

Example 1 with ValueListTypeSabloValue

use of com.servoy.j2db.server.ngclient.property.types.ValueListTypeSabloValue in project servoy-client by Servoy.

the class PersistFieldInstanceTest method testFieldWithValueList.

@Test
public void testFieldWithValueList() throws RepositoryException {
    Form form = solution.getForm("test");
    Assert.assertNotNull(form);
    ValueList vl = solution.getValueList("test");
    Assert.assertNotNull(vl);
    Field field = form.createNewField(new Point(0, 0));
    field.setDataProviderID("mycolumn");
    field.setFormat("#,###.00");
    field.setDisplayType(Field.TYPE_AHEAD);
    field.setValuelistID(vl.getID());
    // needed for a valuelist property type that searches it's form's table via the webform ui
    WebFormUI formUI = new WebFormUI(client.getFormManager().getForm(form.getName()));
    IDataAdapterList dataAdapterList = formUI.getDataAdapterList();
    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), formUI, form);
    Object property = wc.getProperty("valuelistID");
    Assert.assertTrue(property != null ? property.getClass().getName() : "null", property instanceof ValueListTypeSabloValue && ((ValueListTypeSabloValue) property).getValueList() instanceof CustomValueList);
    Assert.assertEquals("#,###.00", ((CustomValueList) ((ValueListTypeSabloValue) property).getValueList()).getFormat().getDisplayFormat());
}
Also used : CustomValueList(com.servoy.j2db.dataprocessing.CustomValueList) Form(com.servoy.j2db.persistence.Form) ValueList(com.servoy.j2db.persistence.ValueList) CustomValueList(com.servoy.j2db.dataprocessing.CustomValueList) IValueList(com.servoy.j2db.dataprocessing.IValueList) ValueListTypeSabloValue(com.servoy.j2db.server.ngclient.property.types.ValueListTypeSabloValue) WebFormComponent(com.servoy.j2db.server.ngclient.WebFormComponent) Point(java.awt.Point) FormElement(com.servoy.j2db.server.ngclient.FormElement) Field(com.servoy.j2db.persistence.Field) WebFormUI(com.servoy.j2db.server.ngclient.WebFormUI) ServoyDataConverterContext(com.servoy.j2db.server.ngclient.ServoyDataConverterContext) IDataAdapterList(com.servoy.j2db.server.ngclient.IDataAdapterList) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) Test(org.junit.Test)

Aggregations

CustomValueList (com.servoy.j2db.dataprocessing.CustomValueList)1 IValueList (com.servoy.j2db.dataprocessing.IValueList)1 Field (com.servoy.j2db.persistence.Field)1 Form (com.servoy.j2db.persistence.Form)1 ValueList (com.servoy.j2db.persistence.ValueList)1 FormElement (com.servoy.j2db.server.ngclient.FormElement)1 IDataAdapterList (com.servoy.j2db.server.ngclient.IDataAdapterList)1 ServoyDataConverterContext (com.servoy.j2db.server.ngclient.ServoyDataConverterContext)1 WebFormComponent (com.servoy.j2db.server.ngclient.WebFormComponent)1 WebFormUI (com.servoy.j2db.server.ngclient.WebFormUI)1 ValueListTypeSabloValue (com.servoy.j2db.server.ngclient.property.types.ValueListTypeSabloValue)1 ServoyJSONObject (com.servoy.j2db.util.ServoyJSONObject)1 Point (java.awt.Point)1 Test (org.junit.Test)1