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());
}
Aggregations