/** * Add a field using the label and components passed in. * * @param label the label to use for the field * @param field the component to use for the field * @return the field which was added to the layout. */ public WField addField(final String label, final WComponent field) { if (null == label) { return addField((WLabel) null, field); } return addField(new WLabel(label), field); }
/** * @param layout the layout to add the fields to * @param table the lookupTable to use on the fields */ private void createFields(final WFieldLayout layout, final Object table) { WDropdown down = new WDropdown(table); down.setType(DropdownType.COMBO); layout.addField("Combo Dropdown", down); WMultiDropdown multi = new WMultiDropdown(table); layout.addField("Multi Dropdown", multi); WMultiSelect select = new WMultiSelect(table); layout.addField("Multi Select", select); }
/** * Add example with no default selection. * @param readOnly if {@code true} then make the example read-only. */ private void addNoSelectionExample(final boolean readOnly) { String label = readOnly ? LABEL_RO_NO_SELECTION : LABEL_NO_SELECTION; WMultiDropdown dropdown = new WMultiDropdown(DATA_LIST); dropdown.setReadOnly(readOnly); layout.addField(label, dropdown); }
/** * Adds the UI artefacts for this PhoneNumberEditPanel. */ private void createUI() { WHeading contactName = new WHeading(HeadingLevel.H3, ""); contactName.setBeanProperty("name"); add(contactName); WFieldLayout fieldLayout = new WFieldLayout(); fieldLayout.addField("Phone", phoneNumField); fieldLayout.addField("Roles", roleSelect); add(fieldLayout); }
/** * Creates a SearchFieldSet. */ private SearchFieldSet() { super("Search for person"); setMargin(new com.github.bordertech.wcomponents.Margin(0, 0, 12, 0)); firstName.setMandatory(true); WFieldLayout fieldLayout = new WFieldLayout(); add(fieldLayout); fieldLayout.addField("First name", firstName); fieldLayout.addField("Last name", lastName); }
public LoginExample() { super("Log in"); setMargin(new Margin(Size.XL)); WPanel content = getContent(); WFieldLayout layout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED); content.add(layout); layout.addField("Name", new WTextField()); layout.addField("Password", new WPasswordField()); layout.addField(new WButton("go")); } }
/** * Add example with one default selection. * @param readOnly if {@code true} then make the example read-only. */ private void addAllSelectionExample(final boolean readOnly) { String label = readOnly ? LABEL_RO_ALL_SELECTED : LABEL_ALL_SELECTED; WMultiDropdown dropdown = new WMultiDropdown(DATA_LIST); dropdown.setSelected(DATA_LIST); dropdown.setReadOnly(readOnly); layout.addField(label, dropdown); }
/** * Creates a NestedContent panel. */ private NestedContent() { WFieldSet fieldSet = new WFieldSet("Fields"); add(fieldSet); WFieldLayout fieldLayout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED); fieldLayout.addField("Checkbox 1", new WCheckBox()); fieldLayout.addField("Checkbox 2", new WCheckBox()); fieldSet.add(fieldLayout); } }
/** * Add example with one default selection. * @param readOnly if {@code true} then make the example read-only. */ private void addOneSelectionExample(final boolean readOnly) { String label = readOnly ? LABEL_RO_ONE_SELECTED : LABEL_ONE_SELECTED; WMultiDropdown dropdown = new WMultiDropdown(DATA_LIST); dropdown.setSelected(DATA_ONE_SELECTED); dropdown.setReadOnly(readOnly); layout.addField(label, dropdown); }
/** * Creates a PanelWithTextField. * * @param fieldLabel the text for the textField's label. */ private PanelWithTextField(final String fieldLabel) { super(); WFieldLayout fieldLayout = new WFieldLayout(WFieldLayout.LAYOUT_FLAT); fieldLayout.setLabelWidth(25); add(fieldLayout); fieldLayout.addField(fieldLabel, textField); }
/** * Add example with one default selection. * @param readOnly if {@code true} then make the example read-only. */ private void addSomeSelectionExample(final boolean readOnly) { String label = readOnly ? LABEL_RO_SOME_SELECTED : LABEL_SOME_SELECTED; WMultiDropdown dropdown = new WMultiDropdown(DATA_LIST); dropdown.setSelected(DATA_SOME_SELECTED); dropdown.setReadOnly(readOnly); layout.addField(label, dropdown); }
/** * Creates the UI artefacts for the ContactContainer. */ private void createUI() { WText headingText = new WText(); WHeading contactName = new WHeading(HeadingLevel.H3, new WDecoratedLabel(null, headingText, deleteButton)); headingText.setBeanProperty("name"); add(contactName); WFieldLayout fieldLayout = new WFieldLayout(); fieldLayout.addField("Phone", phoneNumField); fieldLayout.addField("Roles", roleSelect); add(fieldLayout); add(new WAjaxControl(deleteButton, repeater)); }
/** * Creates a field layout with a couple of fields. * * @return a new field layout with content. */ private WFieldLayout createFieldLayout() { WFieldLayout fieldLayout = new WFieldLayout(); fieldLayout.addField("Field 1", new WTextField()); fieldLayout.addField("Field 2", new WTextArea()).getLabel().setHint("hint"); return fieldLayout; }
/** * Test the Layout is correctly configured. */ @Test public void testRendererCorrectlyConfigured() { WField field = new WFieldLayout().addField("test1", new WTextArea()); Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(field) instanceof WFieldRenderer); }
@Test public void testDoPaintWithFields() throws IOException, SAXException, XpathException { WFieldLayout layout = new WFieldLayout(); layout.addField("Test1", new WTextField()); layout.addField("Test2", new WTextField()); // Validate Schema assertSchemaMatch(layout); // Check Fields assertXpathEvaluatesTo("2", "count(//ui:fieldlayout/ui:field)", layout); }
@Test public void testAddFieldWithStringLabelCreatesWLabel() { WFieldLayout layout = new WFieldLayout(); WField field = layout.addField("Test", new WTextField()); Assert.assertEquals("Expect a WLabel", field.getLabel().getClass(), WLabel.class); }
@Test public void testAddFieldWithStringLabel() { WFieldLayout layout = new WFieldLayout(); WField field = layout.addField("Test", new WTextField()); Assert.assertNotNull(field); }
@Test public void testAddFieldWithWButton() { WFieldLayout layout = new WFieldLayout(); WField field = layout.addField(new WButton("Test")); Assert.assertNotNull(field); }
@Test public void testAddFieldWithWLabel() { WFieldLayout layout = new WFieldLayout(); WField field = layout.addField(new WLabel("Test"), new WTextField()); Assert.assertNotNull(field); }
@Test public void testAddFieldWithWButtonNullLabel() { WFieldLayout layout = new WFieldLayout(); WField field = layout.addField(new WButton("Test")); Assert.assertNull(field.getLabel()); }