Search in sources :

Example 21 with WTextArea

use of com.github.bordertech.wcomponents.WTextArea in project wcomponents by BorderTech.

the class WTextAreaRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    WTextArea field = new WTextArea();
    WButton button = new WButton();
    WContainer root = new WContainer();
    root.add(field);
    root.add(button);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getId(), "//ui:textarea/@id", field);
    assertXpathNotExists("//ui:textarea/@disabled", field);
    assertXpathNotExists("//ui:textarea/@hidden", field);
    assertXpathNotExists("//ui:textarea/@required", field);
    assertXpathNotExists("//ui:textarea/@readOnly", field);
    assertXpathNotExists("//ui:textarea/@minLength", field);
    assertXpathNotExists("//ui:textarea/@maxLength", field);
    assertXpathNotExists("//ui:textarea/@toolTip", field);
    assertXpathNotExists("//ui:textarea/@accessibleText", field);
    assertXpathNotExists("//ui:textarea/@rows", field);
    assertXpathNotExists("//ui:textarea/@cols", field);
    assertXpathNotExists("//ui:textarea/ui:rtf", field);
    field.setDisabled(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:textarea/@disabled", field);
    setFlag(field, ComponentModel.HIDE_FLAG, true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:textarea/@hidden", field);
    field.setMandatory(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:textarea/@required", field);
    field.setMinLength(45);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("45", "//ui:textarea/@minLength", field);
    field.setMaxLength(50);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("50", "//ui:textarea/@maxLength", field);
    field.setToolTip("tooltip");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getToolTip(), "//ui:textarea/@toolTip", field);
    field.setAccessibleText("accessible");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getAccessibleText(), "//ui:textarea/@accessibleText", field);
    field.setRows(20);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("20", "//ui:textarea/@rows", field);
    field.setColumns(40);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("40", "//ui:textarea/@cols", field);
    field.setRichTextArea(false);
    assertSchemaMatch(field);
    assertXpathNotExists("//ui:textarea/ui:rtf", field);
    field.setRichTextArea(true);
    assertSchemaMatch(field);
    assertXpathExists("//ui:textarea/ui:rtf", field);
    field.setDefaultSubmitButton(button);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(button.getId(), "//ui:textarea/@buttonId", field);
    field.setPattern("");
    assertSchemaMatch(field);
    assertXpathNotExists("//ui:textarea/@pattern", field);
    // Pattern is not supported on the client for TextArea, and will not be rendered
    field.setPattern("test[123]");
    assertSchemaMatch(field);
    assertXpathNotExists("//ui:textarea/@pattern", field);
    field.setText("Hello");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getText(), "normalize-space(//ui:textarea)", field);
    field.setPlaceholder("enter stuff here");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("enter stuff here", "//ui:textarea/@placeholder", field);
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WContainer(com.github.bordertech.wcomponents.WContainer) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 22 with WTextArea

use of com.github.bordertech.wcomponents.WTextArea in project wcomponents by BorderTech.

the class WValidationErrorsRenderer_Test method testDoPaintBasic.

@Test
public void testDoPaintBasic() throws IOException, SAXException, XpathException {
    WValidationErrors errors = new WValidationErrors();
    WTextArea text1 = new WTextArea();
    text1.setText("text1");
    WContainer root = new WContainer();
    root.add(errors);
    root.add(text1);
    root.setLocked(true);
    // Validate Schema with no errors
    assertSchemaMatch(root);
    // Simulate Error Message
    setActiveContext(createUIContext());
    List<Diagnostic> diags = new ArrayList<>();
    diags.add(new DiagnosticImpl(Diagnostic.ERROR, text1, "Test Error1"));
    root.showErrorIndicators(diags);
    errors.setErrors(diags);
    assertSchemaMatch(root);
    assertXpathEvaluatesTo(text1.getId(), "//ui:validationerrors/ui:error/@for", root);
    assertXpathEvaluatesTo("Test Error1", "//ui:validationerrors/ui:error", root);
    String title = "WValidationErrorsTitle";
    errors.setTitleText(title);
    assertSchemaMatch(root);
    assertXpathEvaluatesTo(title, "//ui:validationerrors/@title", root);
    // Check for error message with no associated component
    setActiveContext(createUIContext());
    diags.clear();
    diags.add(new DiagnosticImpl(Diagnostic.ERROR, null, "Test Error1"));
    errors.setErrors(diags);
    assertSchemaMatch(root);
    assertXpathNotExists("//ui:validationerrors/ui:error/@for", root);
    assertXpathEvaluatesTo("Test Error1", "//ui:validationerrors/ui:error", root);
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WContainer(com.github.bordertech.wcomponents.WContainer) DiagnosticImpl(com.github.bordertech.wcomponents.validation.DiagnosticImpl) WValidationErrors(com.github.bordertech.wcomponents.validation.WValidationErrors) ArrayList(java.util.ArrayList) Diagnostic(com.github.bordertech.wcomponents.validation.Diagnostic) Test(org.junit.Test)

Example 23 with WTextArea

use of com.github.bordertech.wcomponents.WTextArea in project wcomponents by BorderTech.

the class WFieldRenderer_Test method testRendererCorrectlyConfigured.

/**
 * Test the Layout is correctly configured.
 */
@Test
public void testRendererCorrectlyConfigured() {
    WField field = new WFieldLayout().addField("test1", new WTextArea());
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(field) instanceof WFieldRenderer);
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WField(com.github.bordertech.wcomponents.WField) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) 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