use of com.github.bordertech.wcomponents.WTextArea in project wcomponents by BorderTech.
the class ExpressionBuilder_Test method testTwoArgOrCondition.
@Test
public void testTwoArgOrCondition() {
builder.equals(new WTextField(), "1").or().equals(new WTextArea(), "2");
Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" or WTextArea=\"2\")", builder.build().toString());
}
use of com.github.bordertech.wcomponents.WTextArea in project wcomponents by BorderTech.
the class ExpressionBuilder_Test method testTwoArgAndCondition.
@Test
public void testTwoArgAndCondition() {
builder.equals(new WTextField(), "1").and().equals(new WTextArea(), "2");
Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" and WTextArea=\"2\")", builder.build().toString());
}
use of com.github.bordertech.wcomponents.WTextArea in project wcomponents by BorderTech.
the class ExpressionBuilder_Test method testOrOperatorPrecedenceBoth.
/**
* Tests for correct operator precedence when there are ANDs on both sides of the OR: a || b
* {@literal &}{@literal &} c || d.
*/
@Test
public void testOrOperatorPrecedenceBoth() {
builder.equals(new WTextField(), "1").or().equals(new WTextArea(), "2").and().equals(new WDropdown(), "3").or().equals(new WMultiSelect(), "4");
Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" or ((WTextArea=\"2\" and WDropdown=\"3\") or WMultiSelect=\"4\"))", builder.build().toString());
}
use of com.github.bordertech.wcomponents.WTextArea in project wcomponents by BorderTech.
the class WTextAreaRenderer method doRender.
/**
* Paints the given WTextArea.
*
* @param component the WTextArea to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WTextArea textArea = (WTextArea) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = textArea.isReadOnly();
xml.appendTagOpen("ui:textarea");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", textArea.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
int cols = textArea.getColumns();
int rows = textArea.getRows();
int minLength = textArea.getMinLength();
int maxLength = textArea.getMaxLength();
WComponent submitControl = textArea.getDefaultSubmitButton();
String submitControlId = submitControl == null ? null : submitControl.getId();
xml.appendOptionalAttribute("disabled", textArea.isDisabled(), "true");
xml.appendOptionalAttribute("required", textArea.isMandatory(), "true");
xml.appendOptionalAttribute("minLength", minLength > 0, minLength);
xml.appendOptionalAttribute("maxLength", maxLength > 0, maxLength);
xml.appendOptionalAttribute("toolTip", textArea.getToolTip());
xml.appendOptionalAttribute("accessibleText", textArea.getAccessibleText());
xml.appendOptionalAttribute("rows", rows > 0, rows);
xml.appendOptionalAttribute("cols", cols > 0, cols);
xml.appendOptionalAttribute("buttonId", submitControlId);
xml.appendOptionalAttribute("placeholder", HtmlRenderUtil.getEffectivePlaceholder(textArea));
}
xml.appendClose();
if (textArea.isRichTextArea()) {
/*
* This is a nested element instead of an attribute to cater for future enhancements
* such as turning rich text features on or off, or specifying JSON config either as
* a URL attribute or a nested CDATA section.
*/
xml.append("<ui:rtf />");
}
String textString = textArea.getText();
if (textString != null) {
if (textArea.isReadOnly() && textArea.isRichTextArea()) {
// read only we want to output unescaped, but it must still be XML valid.
xml.write(HtmlToXMLUtil.unescapeToXML(textString));
} else {
xml.appendEscaped(textString);
}
}
if (!readOnly) {
DiagnosticRenderUtil.renderDiagnostics(textArea, renderContext);
}
xml.appendEndTag("ui:textarea");
}
use of com.github.bordertech.wcomponents.WTextArea in project wcomponents by BorderTech.
the class WTextAreaRenderer_Test method testRendererCorrectlyConfigured.
@Test
public void testRendererCorrectlyConfigured() {
WTextArea textArea = new WTextArea();
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(textArea) instanceof WTextAreaRenderer);
}
Aggregations