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"); 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); String placeholder = textArea.getPlaceholder(); xml.appendOptionalAttribute("placeholder", !Util.empty(placeholder), placeholder); String autocomplete = textArea.getAutocomplete();
/** * Creates a RepeaterExampleWithEditableRows. */ public RepeaterExampleWithEditableRows() { repeater = new WRepeater(); repeater.setRepeatedComponent(new PhoneNumberEditPanel()); newNameField = new WTextField(); console = new WTextArea(); console.setColumns(60); console.setRows(5); createExampleUi(); }
@Test public void testSetAutocompleteNullValue() { WTextArea textArea = new WTextArea(); textArea.setAutocomplete(Multiline.STREET_ADDRESS); Assert.assertNotNull(textArea.getAutocomplete()); textArea.setAutocomplete((Multiline) null); Assert.assertNull(textArea.getAutocomplete()); }
@Override public void execute(final ActionEvent event) { disabledTextArea.setDisabled(!disabledTextArea.isDisabled()); } });
@Test public void testDoPaint() throws IOException, SAXException, XpathException { WTextArea field = new WTextArea(); WButton button = new WButton(); assertXpathEvaluatesTo(field.getId(), "//ui:textarea/@id", field); assertXpathNotExists("//ui:textarea/@disabled", field); assertXpathNotExists("//ui:textarea/@hidden", field); field.setDisabled(true); assertSchemaMatch(field); assertXpathEvaluatesTo("true", "//ui:textarea/@disabled", 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");
final WTextArea defaultTextArea = new WTextArea(); WTextArea constrainedTextArea = new WTextArea(); constrainedTextArea.setColumns(40); constrainedTextArea.setRows(4); constrainedTextArea.setMaxLength(200); constrainedTextArea.setPlaceholder("type here"); final WTextArea readOnlyTextArea = new WTextArea(); readOnlyTextArea.setReadOnly(true); readOnlyTextArea.setText("This is read only."); final WTextArea disabledTextArea = new WTextArea(); disabledTextArea.setDisabled(true); disabledTextArea.setText("This is disabled."); final WTextArea readOnlyReflector = new WTextArea(); readOnlyReflector.setReadOnly(true); WTextArea initiallyInvalid = new WTextArea(); initiallyInvalid.setMaxLength(10); initiallyInvalid.setText("abc\ndef\ngh"); final WTextArea rtf = new WTextArea(); rtf.setRichTextArea(true); final WTextArea rtfReadOnly = new WTextArea(); rtfReadOnly.setReadOnly(true); rtfReadOnly.setRichTextArea(true);
@Test public void testSanitizeOnOutput() { WTextArea textArea = new WTextArea(); textArea.setData("<form>content</form>"); textArea.setSanitizeOnOutput(true); // do not setRichText until after setData otherwise content will be sanitized on setData textArea.setRichTextArea(true); Assert.assertEquals("Expect output to be sanitized", "content", textArea.getText()); }
/** * Creates a SuccessComponent. */ public SuccessComponent() { add(new WMessageBox(WMessageBox.SUCCESS, "All is valid!")); beanDetails = new WTextArea(); beanDetails.setRows(15); beanDetails.setColumns(60); beanDetails.setReadOnly(true); add(beanDetails); }
@Test public void testRendererCorrectlyConfigured() { WTextArea textArea = new WTextArea(); Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(textArea) instanceof WTextAreaRenderer); }
textArea = new WTextArea(); textArea.setRows(5); textArea.setColumns(50); textArea.setMaxLength(300); textArea.setMandatory(true); WField textAreaField = fields.addField("WTextArea", textArea); textAreaField.getLabel().setHint("required with a maximum of 300 characters");
/** * Set up the WPanel so that the appropriate items are visible based on configuration settings. */ public void updateUI() { if (!Util.empty(panelContent.getText())) { panelContentRO.setData(panelContent.getData()); } else { panelContentRO.setText(SAMPLE_CONTENT); } panel.setType((WPanel.Type) panelType.getSelected()); String headingText = tfHeading.getText(); if (!Util.empty(tfHeading.getText())) { heading.setText(tfHeading.getText()); panel.setTitleText(headingText); } else { heading.setText(SAMPLE_HEADER); panel.setTitleText(SAMPLE_TITLE_TEXT); } }
@Test public void testSetFullAddressAutocompleteWithNullType() { WTextArea textArea = new WTextArea(); textArea.setFullStreetAddressAutocomplete(null); Assert.assertEquals(Multiline.STREET_ADDRESS.getValue(), textArea.getAutocomplete()); }
heading = new WHeading(HeadingLevel.H1, SAMPLE_HEADER); utilBar = new WPanel(); panelContent = new WTextArea(); panelContentRO = new WTextArea(); showUtilBar = new WCheckBox(true); showMenu = new WCheckBox(true); panelContentRO.setReadOnly(true); panelContent.setRichTextArea(true); panelContentRO.setRichTextArea(true); panelType.setOptions(WPanel.Type.values()); panelType.setSelected(WPanel.Type.PLAIN); panelContent.setText(SAMPLE_CONTENT); panelContentRO.setText(SAMPLE_CONTENT); tfHeading.setText(SAMPLE_HEADER);
@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); } }
@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); }
@Override public void execute(final ActionEvent event) { comment2.setText(textComment.getText()); } });
/** * Creates a RepeaterComponent. */ public RepeaterComponent() { setLayout(new FlowLayout(Alignment.VERTICAL)); repeater.setRepeatedComponent(new BasicComponent()); WFieldSet fieldset = new WFieldSet("Group"); add(fieldset); fieldset.add(repeater); selectorBtn.setAction(new Action() { @Override public void execute(final ActionEvent event) { show(); } }); add(selectorBtn); selectorText.setRows(10); selectorText.setColumns(50); selectorText.setReadOnly(true); add(selectorText); }