use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.
the class WRadioButtonSelectExample method addReadOnlyExamples.
/**
* Examples of readonly states. When in a read only state only the selected option is output. Since a
* WRadioButtonSeelct can only have 0 or 1 selected option the LAYOUT and FRAME are ignored.
*/
private void addReadOnlyExamples() {
add(new WHeading(HeadingLevel.H3, "Read-only WRadioButtonSelect examples"));
add(new ExplanatoryText("These examples all use the same list of options: the states and territories list from the editable examples above. " + "When the readOnly state is specified only that option which is selected is output.\n" + "Since no more than one option is able to be selected the layout and frame settings are ignored in the read only state."));
WFieldLayout layout = new WFieldLayout();
add(layout);
WRadioButtonSelect select = new WRadioButtonSelect("australian_state");
select.setReadOnly(true);
layout.addField("Read only with no selection", select);
select = new SelectWithSelection("australian_state");
select.setReadOnly(true);
layout.addField("Read only with selection", select);
}
use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.
the class WCheckBoxExample_Test method testFindByLabelId.
/**
* Test that ByLabel works for CheckBoxes by label id.
*/
@Test
public void testFindByLabelId() {
// Launch the web browser to the LDE
WebDriver driver = getDriver();
WContainer container = (WContainer) getUi();
WFieldLayout layout = (WFieldLayout) container.getChildAt(0);
WField field = (WField) layout.getChildAt(0);
String labelId = field.getLabel().getId();
String componentId = field.getField().getId();
WebElement checkBox = driver.findElement(new ByLabel(labelId));
Assert.assertNotNull("Unable to find checkbox by labelId", checkBox);
Assert.assertEquals("Checkbox element ID does not match expected", componentId, checkBox.getAttribute("id"));
}
use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.
the class AbstractSetMandatory_Test method testExecute.
@Test
public void testExecute() {
// ---------------------
// Valid Target (WInput) and TRUE Boolean Value
SubordinateTarget target1 = new MyTarget();
AbstractSetMandatory mandatory = new MyMandatory(target1, Boolean.TRUE);
// Should be mandatory
mandatory.execute();
Assert.assertTrue("Target (Mandatable) should be mandatory", ((Mandatable) target1).isMandatory());
// FALSE Boolean Value
mandatory = new MyMandatory(target1, Boolean.FALSE);
// Should not be mandatory
mandatory.execute();
Assert.assertFalse("Target (Mandatable) should not be mandatory", ((Mandatable) target1).isMandatory());
// ---------------------
// Valid Target (WField) and TRUE Boolean Value
Input textArea = new WTextArea();
WField target2 = new WFieldLayout().addField("test", textArea);
mandatory = new MyMandatory(target2, Boolean.TRUE);
// Should be mandatory
mandatory.execute();
Assert.assertTrue("Target (WField) should be mandatory", textArea.isMandatory());
// FALSE Boolean Value
mandatory = new MyMandatory(target2, Boolean.FALSE);
// Should not be mandatory
mandatory.execute();
Assert.assertFalse("Target (WField) should not be mandatory", textArea.isMandatory());
// ---------------------
// Valid Target (WFieldSet) and TRUE Boolean Value
WFieldSet target3 = new WFieldSet("Test");
mandatory = new MyMandatory(target3, Boolean.TRUE);
// Should be mandatory
mandatory.execute();
Assert.assertTrue("Target (WFieldSet) should be mandatory", target3.isMandatory());
// FALSE Boolean Value
mandatory = new MyMandatory(target3, Boolean.FALSE);
// Should not be mandatory
mandatory.execute();
Assert.assertFalse("Target (WFieldSet) should not be mandatory", target3.isMandatory());
// ---------------------
// Invalid Target (Cannot be set Mandatory) and Boolean Value
MyInvalidTarget target4 = new MyInvalidTarget();
mandatory = new MyMandatory(target4, Boolean.TRUE);
// Should do nothing
mandatory.execute();
}
use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.
the class WFieldLayoutRenderer method doRender.
/**
* Paints the given WFieldLayout.
*
* @param component the WFieldLayout to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WFieldLayout fieldLayout = (WFieldLayout) component;
XmlStringBuilder xml = renderContext.getWriter();
int labelWidth = fieldLayout.getLabelWidth();
String title = fieldLayout.getTitle();
xml.appendTagOpen("ui:fieldlayout");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", fieldLayout.isHidden(), "true");
xml.appendOptionalAttribute("labelWidth", labelWidth > 0, labelWidth);
xml.appendAttribute("layout", fieldLayout.getLayoutType());
xml.appendOptionalAttribute("title", title);
// Ordered layout
if (fieldLayout.isOrdered()) {
xml.appendAttribute("ordered", fieldLayout.getOrderedOffset());
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(fieldLayout, renderContext);
// Paint Fields
paintChildren(fieldLayout, renderContext);
xml.appendEndTag("ui:fieldlayout");
}
use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.
the class WFieldLayoutRenderer_Test method testDoPaintBasic.
@Test
public void testDoPaintBasic() throws IOException, SAXException, XpathException {
WFieldLayout layout = new WFieldLayout();
// Validate Schema
assertSchemaMatch(layout);
// Check Attributes
assertXpathEvaluatesTo(layout.getId(), "//ui:fieldlayout/@id", layout);
assertXpathEvaluatesTo("flat", "//ui:fieldlayout/@layout", layout);
assertXpathEvaluatesTo("", "//ui:fieldlayout/@hidden", layout);
assertXpathEvaluatesTo("", "//ui:fieldlayout/@labelWidth", layout);
assertXpathEvaluatesTo("", "//ui:fieldlayout/@title", layout);
assertXpathEvaluatesTo("", "//ui:fieldlayout/@ordered", layout);
// Check No Fields
assertXpathNotExists("//ui:fieldlayout/ui:field", layout);
}
Aggregations