Search in sources :

Example 1 with WTextArea

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

the class WTextAreaRenderer_Test method testReadOnly.

@Test
public void testReadOnly() throws IOException, SAXException, XpathException {
    WTextArea field = new WTextArea();
    field.setReadOnly(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:textarea/@readOnly", field);
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) Test(org.junit.Test)

Example 2 with WTextArea

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

the class WTextAreaRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WTextArea textArea = new WTextArea();
    textArea.setText(getMaliciousContent());
    assertSafeContent(textArea);
    textArea.setToolTip(getMaliciousAttribute("ui:textarea"));
    assertSafeContent(textArea);
    textArea.setAccessibleText(getMaliciousAttribute("ui:textarea"));
    assertSafeContent(textArea);
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) Test(org.junit.Test)

Example 3 with WTextArea

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

the class WLabelRenderer_Test method testDoPaintAllOptions.

@Test
public void testDoPaintAllOptions() throws IOException, SAXException, XpathException {
    WTextArea text = new WTextArea();
    text.setText("text1");
    WLabel label = new WLabel();
    label.setForComponent(text);
    label.setHint("hint1");
    label.setAccessKey('A');
    label.setText("label1");
    WContainer root = new WContainer();
    root.add(label);
    root.add(text);
    // Validate Schema
    assertSchemaMatch(root);
    // Check Attributes
    assertXpathEvaluatesTo(label.getId(), "//ui:label/@id", label);
    assertXpathEvaluatesTo(text.getId(), "//ui:label/@for", label);
    assertXpathEvaluatesTo("hint1", "//ui:label/@hint", label);
    assertXpathEvaluatesTo("A", "//ui:label/@accessKey", label);
    assertXpathEvaluatesTo("input", "//ui:label/@what", label);
    // Check Label
    assertXpathEvaluatesTo("label1", "//ui:label", label);
    // Add Children to Label
    WTextArea text2 = new WTextArea();
    text2.setText("text2");
    label.add(text2);
    assertSchemaMatch(root);
    assertXpathEvaluatesTo("text2", "//ui:label/ui:textarea", label);
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WContainer(com.github.bordertech.wcomponents.WContainer) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 4 with WTextArea

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

the class TreeUtil_Test method initTree.

@Before
public void initTree() {
    root = new WApplication();
    containerChild = new WContainer();
    simpleChild = new WTextField();
    repeatedComponent = new WText();
    repeaterChild = new WRepeater(repeatedComponent);
    grandChild = new WTextArea();
    cardManager = new WCardManager();
    card1 = new WText();
    card2 = new WText();
    root.add(containerChild);
    root.add(simpleChild);
    root.add(repeaterChild);
    root.add(cardManager);
    containerChild.add(grandChild);
    cardManager.add(card1);
    cardManager.add(card2);
    root.setLocked(true);
    setActiveContext(new UIContextImpl());
    repeaterChild.setData(Arrays.asList(new String[] { "1", "2", "3" }));
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WContainer(com.github.bordertech.wcomponents.WContainer) WApplication(com.github.bordertech.wcomponents.WApplication) WText(com.github.bordertech.wcomponents.WText) UIContextImpl(com.github.bordertech.wcomponents.UIContextImpl) WCardManager(com.github.bordertech.wcomponents.WCardManager) WTextField(com.github.bordertech.wcomponents.WTextField) WRepeater(com.github.bordertech.wcomponents.WRepeater) Before(org.junit.Before)

Example 5 with WTextArea

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

the class WLabelExample method addAntiPatternExamples.

/**
 * Add examples you should never follow. DO NOT use the following as examples of what to do: these are examples of what NOT to do.
 */
private void addAntiPatternExamples() {
    add(new WHeading(HeadingLevel.H2, "WLabel anti-patterns"));
    add(new ExplanatoryText("These are here for testing purposes and must not be used as examples to follow.\n" + "Turn on debugging (bordertech.wcomponents.debug.enabled=true) to get much more information."));
    add(new WHeading(HeadingLevel.H3, "Poor but not erroneous uses of WLabel"));
    WPanel errorLayoutPanel = new WPanel();
    errorLayoutPanel.setLayout(new FlowLayout(FlowLayout.VERTICAL, Size.LARGE));
    add(errorLayoutPanel);
    // label not for anything should not be a WLabel
    errorLayoutPanel.add(new WLabel("I am not 'for' anything"));
    // WLabel for something which is not labellable
    errorLayoutPanel.add(new WLabel("I am for a component which should not be labelled", errorLayoutPanel));
    // If the WLabel is 'for' something that is not in the tree it becomes 'for' the WApplication. This is not necessarily a good thing!!!
    WCheckBox notHere = new WCheckBox();
    errorLayoutPanel.add(new WLabel("My component wasn't added", notHere));
    /*
		 * The examples which follow MUST NEVER BE USED! They cause ERRORS.
		 * They are here purely for framework testing.
		 */
    add(new WHeading(HeadingLevel.H3, "Very bad uses of WLabel"));
    errorLayoutPanel = new WPanel();
    errorLayoutPanel.setLayout(new FlowLayout(FlowLayout.VERTICAL, Size.LARGE));
    add(errorLayoutPanel);
    /*
		 * Nested WLabels: very bad
		 */
    errorLayoutPanel.add(new ExplanatoryText("This example shows nested WLabels. This is a contravention of the HTML specification."));
    WPanel nestingErrorPanel = new WPanel();
    nestingErrorPanel.setLayout(new ColumnLayout(new int[] { 50, 50 }, Size.LARGE, Size.MEDIUM));
    errorLayoutPanel.add(nestingErrorPanel);
    WTextField outerField = new WTextField();
    WLabel outerLabel = new WLabel("I am an outer label", outerField);
    nestingErrorPanel.add(outerLabel);
    WTextField innerField = new WTextField();
    WLabel innerLabel = new WLabel("Inner label", innerField);
    // add the inner label to the outer label: this is the ERROR
    outerLabel.add(innerLabel);
    nestingErrorPanel.add(innerField);
    nestingErrorPanel.add(outerField);
    /*
		 * It is permissible to place certain simple form control components into
		 * a WLabel under the following conditions:
		 * there must be no more than one such component in the WLabel;
		 * the component MUST be one which outputs a simple HTML form control
		 * (and I am not going to tell you which they are);
		 * The WLabel must be 'for' the nested component or not 'for' anything.
		 */
    errorLayoutPanel.add(new ExplanatoryText("This example shows a WLabel with a nested simple form control WTextField but the WLabel is not " + "'for' the WTextField. This is a contravention of the HTML specification."));
    WTextField notMyField = new WTextField();
    notMyField.setToolTip("This field should not be in the label it is in");
    WTextField myField = new WTextField();
    WLabel myFieldLabel = new WLabel("I am not the label for my nested text field", myField);
    nestingErrorPanel = new WPanel();
    nestingErrorPanel.setLayout(new ColumnLayout(new int[] { 50, 50 }, Size.LARGE, Size.MEDIUM));
    errorLayoutPanel.add(nestingErrorPanel);
    nestingErrorPanel.add(myFieldLabel);
    nestingErrorPanel.add(myField);
    // adding the 'wrong' WTextField to a WLabel is what causes this error
    myFieldLabel.add(notMyField);
    add(new ExplanatoryText("The next field has a label explicitly set to only white space."));
    WTextField emptyLabelTextField = new WTextField();
    WLabel emptyLabel = new WLabel(" ", emptyLabelTextField);
    add(emptyLabel);
    add(emptyLabelTextField);
    add(new WHeading(HeadingLevel.H2, "Unlabelled controls"));
    add(new ExplanatoryText("These controls must be labelled but are not."));
    WFieldLayout fieldsFlat = new WFieldLayout();
    add(fieldsFlat);
    fieldsFlat.addField((WLabel) null, new WTextField());
    fieldsFlat.addField((WLabel) null, new WTextArea());
    fieldsFlat.addField((WLabel) null, new WDateField());
    fieldsFlat.addField((WLabel) null, new WCheckBox());
    fieldsFlat.addField((WLabel) null, new WCheckBoxSelect(new String[] { "Apple", "Cherry", "Orange", "Pineapple" }));
}
Also used : FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) WPanel(com.github.bordertech.wcomponents.WPanel) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WCheckBox(com.github.bordertech.wcomponents.WCheckBox) WHeading(com.github.bordertech.wcomponents.WHeading) WLabel(com.github.bordertech.wcomponents.WLabel) WTextArea(com.github.bordertech.wcomponents.WTextArea) ColumnLayout(com.github.bordertech.wcomponents.layout.ColumnLayout) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WDateField(com.github.bordertech.wcomponents.WDateField) WTextField(com.github.bordertech.wcomponents.WTextField) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect)

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