FormWidget testForm = new FormWidget();
testForm._getComponent().init(new MockEnviroment());
//Adding elements to form
testForm.addElement("myCheckBox", "my checkbox", new CheckboxControl(), new BooleanData(), true);
testForm.addElement("myLongText", "my long text", new TextControl(), new LongData(), true);
testForm.addElement("myDateTime", "my date and time", new DateTimeControl(), new DateData(), false);
testForm.addElement("myButton", "my button", new ButtonControl(), null, false);
//Adding a composite element
FormWidget hierarchyTest = testForm.addSubForm("hierarchyTest");
hierarchyTest.addElement("myTextarea", "my text area", new TextareaControl(), new StringData(), true);
//Filling in select control (which is under a composite element)
FormElement mySelectElement = hierarchyTest.addElement("mySelect", "my drop down", new SelectControl(), new LongData(), true);
SelectControl mySelect = (SelectControl) mySelectElement.getControl();
mySelect.addItem(new DisplayItem("1", "one"));
mySelect.addItem(new DisplayItem("2", "two"));
mySelect.addItem(new DisplayItem("3", "three"));
mySelect.addItem(new DisplayItem("4", "four"));