use of com.github.bordertech.wcomponents.WMultiDropdown in project wcomponents by BorderTech.
the class LoadAjaxControlsExample method createFields.
/**
* @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);
}
use of com.github.bordertech.wcomponents.WMultiDropdown in project wcomponents by BorderTech.
the class WMultiDropdownTestingExample method addSomeSelectionExample.
/**
* 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);
}
use of com.github.bordertech.wcomponents.WMultiDropdown in project wcomponents by BorderTech.
the class WMultiDropdownTestingExample method setupUI.
/**
* Build the UI.
*/
private void setupUI() {
add(layout);
// no default selection (first option is deemed selected)
addNoSelectionExample(false);
addOneSelectionExample(false);
addSomeSelectionExample(false);
addAllSelectionExample(false);
// readOnly
addNoSelectionExample(true);
addOneSelectionExample(true);
addSomeSelectionExample(true);
addAllSelectionExample(true);
// disabled
WMultiDropdown dropdown = new WMultiDropdown(DATA_LIST);
dropdown.setSelected(DATA_SOME_SELECTED);
dropdown.setDisabled(true);
layout.addField(LABEL_DISABLED, dropdown);
// mandatory
dropdown = new WMultiDropdown(DATA_LIST);
dropdown.setSelected(DATA_SOME_SELECTED);
dropdown.setMandatory(true);
layout.addField(LABEL_MANDATORY, dropdown);
// add a reset button
layout.addField(resetButton);
}
use of com.github.bordertech.wcomponents.WMultiDropdown in project wcomponents by BorderTech.
the class WMultiDropdownRenderer method doRender.
/**
* Paints the given WMultiDropdown.
*
* @param component the WMultiDropdown to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WMultiDropdown dropdown = (WMultiDropdown) component;
XmlStringBuilder xml = renderContext.getWriter();
String dataKey = dropdown.getListCacheKey();
boolean readOnly = dropdown.isReadOnly();
xml.appendTagOpen("ui:multidropdown");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", dropdown.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
xml.appendOptionalAttribute("data", dataKey != null && !readOnly, dataKey);
xml.appendOptionalAttribute("disabled", dropdown.isDisabled(), "true");
xml.appendOptionalAttribute("required", dropdown.isMandatory(), "true");
xml.appendOptionalAttribute("submitOnChange", dropdown.isSubmitOnChange(), "true");
xml.appendOptionalAttribute("toolTip", component.getToolTip());
xml.appendOptionalAttribute("accessibleText", component.getAccessibleText());
int min = dropdown.getMinSelect();
int max = dropdown.getMaxSelect();
xml.appendOptionalAttribute("min", min > 0, min);
xml.appendOptionalAttribute("max", max > 0, max);
xml.appendOptionalAttribute("title", I18nUtilities.format(null, InternalMessages.DEFAULT_MULTI_FORM_COMPONENT_TIP));
}
xml.appendClose();
// Options
List<?> options = dropdown.getOptions();
boolean renderSelectionsOnly = dropdown.isReadOnly() || dataKey != null;
if (options != null) {
int optionIndex = 0;
List<?> selections = dropdown.getSelected();
for (Object option : options) {
if (option instanceof OptionGroup) {
xml.appendTagOpen("ui:optgroup");
xml.appendAttribute("label", ((OptionGroup) option).getDesc());
xml.appendClose();
for (Object nestedOption : ((OptionGroup) option).getOptions()) {
renderOption(dropdown, nestedOption, optionIndex++, xml, selections, renderSelectionsOnly);
}
xml.appendEndTag("ui:optgroup");
} else {
renderOption(dropdown, option, optionIndex++, xml, selections, renderSelectionsOnly);
}
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(dropdown, renderContext);
}
// End tag
xml.appendEndTag("ui:multidropdown");
}
use of com.github.bordertech.wcomponents.WMultiDropdown in project wcomponents by BorderTech.
the class WLabelRenderer_Test method testWhatForGroup2.
@Test
public void testWhatForGroup2() throws IOException, SAXException, XpathException {
WMultiDropdown comp = new WMultiDropdown();
WLabel label = new WLabel("label", comp);
assertXpathEvaluatesTo("group", "//ui:label/@what", label);
}
Aggregations