use of com.github.bordertech.wcomponents.WCheckBoxSelect in project wcomponents by BorderTech.
the class WListOptionsExample method getBeanFieldsCheckBoxSelect.
/**
* This builds and returns a WCheckbox group containing the list of fields on the {@link SimpleTableBean}.
*
* @return a WCheckBoxSelect
*/
private WCheckBoxSelect getBeanFieldsCheckBoxSelect() {
List<String> options = new ArrayList<>();
options.add("Name");
options.add("Type");
options.add("Thing");
List<String> defaults = new ArrayList<>();
defaults.add("Name");
WCheckBoxSelect cgproperties = new WCheckBoxSelect(options);
cgproperties.setSelected(defaults);
return cgproperties;
}
use of com.github.bordertech.wcomponents.WCheckBoxSelect in project wcomponents by BorderTech.
the class WDropdownSpaceHandlingExample_Test method testCheckbox.
@Test
public void testCheckbox() {
WDropdownSpaceHandlingExample example = (WDropdownSpaceHandlingExample) getUi();
// Launch the web browser to the LDE
SeleniumWComponentsWebDriver driver = getDriver();
UIContext uic = getUserContextForSession();
UIContextHolder.pushContext(uic);
try {
WCheckBoxSelect group = (WCheckBoxSelect) TreeUtil.findWComponent(example, new String[] { "WCheckBoxSelect" }).getComponent();
List<?> options = group.getOptions();
for (Object option : options) {
driver.findElement(byWComponent(group, option)).click();
driver.findElement(byWComponentPath("WButton")).click();
Assert.assertEquals("Incorrect option selected", option, group.getSelected().get(0));
// De-select option
driver.findElement(byWComponent(group, option)).click();
}
} finally {
UIContextHolder.popContext();
}
}
use of com.github.bordertech.wcomponents.WCheckBoxSelect in project wcomponents by BorderTech.
the class WCheckBoxSelectRenderer method doRender.
/**
* Paints the given WCheckBoxSelect.
*
* @param component the WCheckBoxSelect to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WCheckBoxSelect select = (WCheckBoxSelect) component;
XmlStringBuilder xml = renderContext.getWriter();
int cols = select.getButtonColumns();
boolean readOnly = select.isReadOnly();
xml.appendTagOpen("ui:checkboxselect");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", select.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
int min = select.getMinSelect();
int max = select.getMaxSelect();
xml.appendOptionalAttribute("disabled", select.isDisabled(), "true");
xml.appendOptionalAttribute("required", select.isMandatory(), "true");
xml.appendOptionalAttribute("submitOnChange", select.isSubmitOnChange(), "true");
xml.appendOptionalAttribute("toolTip", component.getToolTip());
xml.appendOptionalAttribute("accessibleText", component.getAccessibleText());
xml.appendOptionalAttribute("min", min > 0, min);
xml.appendOptionalAttribute("max", max > 0, max);
}
xml.appendOptionalAttribute("frameless", select.isFrameless(), "true");
switch(select.getButtonLayout()) {
case COLUMNS:
xml.appendAttribute("layout", "column");
xml.appendOptionalAttribute("layoutColumnCount", cols > 0, cols);
break;
case FLAT:
xml.appendAttribute("layout", "flat");
break;
case STACKED:
xml.appendAttribute("layout", "stacked");
break;
default:
throw new SystemException("Unknown layout type: " + select.getButtonLayout());
}
xml.appendClose();
// Options
List<?> options = select.getOptions();
boolean renderSelectionsOnly = readOnly;
if (options != null) {
int optionIndex = 0;
List<?> selections = select.getSelected();
for (Object option : options) {
if (option instanceof OptionGroup) {
throw new SystemException("Option groups not supported in WCheckBoxSelect.");
} else {
renderOption(select, option, optionIndex++, xml, selections, renderSelectionsOnly);
}
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(select, renderContext);
}
xml.appendEndTag("ui:checkboxselect");
}
use of com.github.bordertech.wcomponents.WCheckBoxSelect in project wcomponents by BorderTech.
the class WLabelRenderer_Test method testWhatForGroup1.
@Test
public void testWhatForGroup1() throws IOException, SAXException, XpathException {
WCheckBoxSelect comp = new WCheckBoxSelect();
WLabel label = new WLabel("label", comp);
assertSchemaMatch(label);
assertXpathEvaluatesTo("group", "//ui:label/@what", label);
}
use of com.github.bordertech.wcomponents.WCheckBoxSelect in project wcomponents by BorderTech.
the class WCheckBoxSelectRenderer_Test method testDoPaintAllOptions.
@Test
public void testDoPaintAllOptions() throws IOException, SAXException, XpathException {
WCheckBoxSelect wcbTest = new WCheckBoxSelect(new String[] { "a", "b", "c" });
assertSchemaMatch(wcbTest);
wcbTest.setDisabled(true);
setFlag(wcbTest, ComponentModel.HIDE_FLAG, true);
wcbTest.setMandatory(true);
wcbTest.setSubmitOnChange(true);
wcbTest.setToolTip("tool tip");
wcbTest.setAccessibleText("accessible text");
wcbTest.setFrameless(true);
wcbTest.setMinSelect(1);
wcbTest.setMaxSelect(2);
assertSchemaMatch(wcbTest);
assertXpathEvaluatesTo(wcbTest.getId(), "//ui:checkboxselect/@id", wcbTest);
assertXpathEvaluatesTo("true", "//ui:checkboxselect/@disabled", wcbTest);
assertXpathEvaluatesTo("true", "//ui:checkboxselect/@hidden", wcbTest);
assertXpathEvaluatesTo("true", "//ui:checkboxselect/@required", wcbTest);
assertXpathEvaluatesTo("true", "//ui:checkboxselect/@submitOnChange", wcbTest);
assertXpathEvaluatesTo("tool tip", "//ui:checkboxselect/@toolTip", wcbTest);
assertXpathEvaluatesTo("accessible text", "//ui:checkboxselect/@accessibleText", wcbTest);
assertXpathEvaluatesTo("true", "//ui:checkboxselect/@frameless", wcbTest);
assertXpathEvaluatesTo("1", "//ui:checkboxselect/@min", wcbTest);
assertXpathEvaluatesTo("2", "//ui:checkboxselect/@max", wcbTest);
// Button Layouts
wcbTest.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
wcbTest.setButtonColumns(3);
assertXpathEvaluatesTo("column", "//ui:checkboxselect/@layout", wcbTest);
assertXpathEvaluatesTo("3", "//ui:checkboxselect/@layoutColumnCount", wcbTest);
wcbTest.setButtonLayout(WCheckBoxSelect.LAYOUT_FLAT);
assertXpathEvaluatesTo("flat", "//ui:checkboxselect/@layout", wcbTest);
assertXpathNotExists("//ui:checkboxselect/@layoutColumnCount", wcbTest);
wcbTest.setButtonLayout(WCheckBoxSelect.LAYOUT_STACKED);
assertXpathEvaluatesTo("stacked", "//ui:checkboxselect/@layout", wcbTest);
assertXpathNotExists("//ui:checkboxselect/@layoutColumnCount", wcbTest);
}
Aggregations