Search This Blog

SmartGWT: how to add unknown number of form items to a form

In SmartGWT, the DynamicForm class has only setItems(FormItem[] items) method to use.

To add a list of form items to a form, while the number of items are not known, you can use following code:


Vector<formitem> items = new Vector<formitem>();
TextItem textItem1 = new TextItem();
items.add(textItem1);
...
TextItem textItem2 = new TextItem();
items.add(textItem2);
...

FormItem[] formItems = new FormItem[items.size()];
items.toArray(formItems);
form.setItems(formItems);

No comments:

Post a Comment