Search in sources :

Example 16 with WTextArea

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());
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 17 with WTextArea

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());
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 18 with WTextArea

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());
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WDropdown(com.github.bordertech.wcomponents.WDropdown) WTextField(com.github.bordertech.wcomponents.WTextField) WMultiSelect(com.github.bordertech.wcomponents.WMultiSelect) Test(org.junit.Test)

Example 19 with WTextArea

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");
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WComponent(com.github.bordertech.wcomponents.WComponent) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 20 with WTextArea

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);
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) Test(org.junit.Test)

Aggregations

WTextArea (com.github.bordertech.wcomponents.WTextArea)23 Test (org.junit.Test)19 WTextField (com.github.bordertech.wcomponents.WTextField)14 WDropdown (com.github.bordertech.wcomponents.WDropdown)10 WMultiSelect (com.github.bordertech.wcomponents.WMultiSelect)5 WContainer (com.github.bordertech.wcomponents.WContainer)4 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)4 WLabel (com.github.bordertech.wcomponents.WLabel)3 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)2 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)2 WDateField (com.github.bordertech.wcomponents.WDateField)2 WField (com.github.bordertech.wcomponents.WField)2 WFieldSet (com.github.bordertech.wcomponents.WFieldSet)2 WText (com.github.bordertech.wcomponents.WText)2 Input (com.github.bordertech.wcomponents.Input)1 RadioButtonGroup (com.github.bordertech.wcomponents.RadioButtonGroup)1 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)1 UIContextImpl (com.github.bordertech.wcomponents.UIContextImpl)1 WApplication (com.github.bordertech.wcomponents.WApplication)1 WButton (com.github.bordertech.wcomponents.WButton)1