/** * Creates a transfer panel. */ private TransferPanel() { super(WPanel.Type.BLOCK); setLayout(new FlowLayout(Alignment.VERTICAL, 0, 10)); add(new WHeading(WHeading.SECTION, "Transfer details")); WStyledText text = new WStyledText( "If paying by electronic transfer:" + "\n \u00b7 Payments must be received within seven days of submitting the order." + "\n \u00b7 If payment is not received within seven days, the order will be discarded." + "\n \u00b7 Use only your invoice number as the lodgement reference." + "\n\nAccount details\nBank: example bank\nAcct No.: 0123456789\nAcct Name: example name" ); text.setWhitespaceMode(WStyledText.WhitespaceMode.PARAGRAPHS); add(text); } }
@Override public void execute(final ActionEvent event) { styled.reset(); styled.setType((WStyledText.Type) type.getSelected()); styled.setWhitespaceMode((WStyledText.WhitespaceMode) mode.getSelected()); styled.setText(text.getText()); styled.setHtmlClass(useBigTextClass.isSelected() ? "bigText" : null); styled.setEncodeText(cbEncodeText.isSelected()); // text.setRichTextArea(cbEncodeText.isSelected()); } });
@Test public void testXssEscaping() throws IOException, SAXException, XpathException { WStyledText styledText = new WStyledText(getMaliciousContent()); assertSafeContent(styledText); styledText.setToolTip(getMaliciousAttribute("ui:textfield")); assertSafeContent(styledText); styledText.setAccessibleText(getMaliciousAttribute("ui:textfield")); assertSafeContent(styledText); styledText.setWhitespaceMode(WStyledText.WhitespaceMode.PRESERVE); assertSafeContent(styledText); styledText.setWhitespaceMode(WStyledText.WhitespaceMode.PARAGRAPHS); assertSafeContent(styledText); }
/** * Builds a panel for the subordinate control, including the rule for that particular option. * * @param dropdown the subordinate trigger. * @param value the dropdown option to be added * @param group the group * @param control the subordinate control */ private void buildSubordinatePanel(final WDropdown dropdown, final String value, final WComponentGroup<SubordinateTarget> group, final WSubordinateControl control) { // create the panel. WPanel panel = new WPanel(); WStyledText subordinateInfo = new WStyledText(); subordinateInfo.setWhitespaceMode(WhitespaceMode.PRESERVE); subordinateInfo.setText(value + " - Subordinate"); panel.add(subordinateInfo); // add the panel to the screen and group. infoPanel.add(panel); group.addToGroup(panel); // create the rule Rule rule = new Rule(); control.addRule(rule); rule.setCondition(new Equal(dropdown, value)); rule.addActionOnTrue(new ShowInGroup(panel, group)); }
/** * Generate some content for the tabs. * @param dateText some text to include in the content * @return a WContainer with content. */ private WContainer sampleTabContent(final String dateText) { WContainer container = new WContainer(); WStyledText txt = new WStyledText((new DateText(dateText)).getText()); txt.setWhitespaceMode(WStyledText.WhitespaceMode.PARAGRAPHS); container.add(txt); WFieldLayout layout = new WFieldLayout(WFieldLayout.LAYOUT_FLAT); layout.setLabelWidth(25); container.add(layout); layout.addField("Who are you?", new WTextField()); layout.addField("I like bananas", new WCheckBox()); layout.addField(new WButton("Save")); return container; } }
/** * Create the WHiddenComment example. */ public WHiddenCommentExample() { add(new WHeading(WHeading.SECTION, "Hidden Comments Example")); WStyledText text = new WStyledText( "Right click the page to view the source and the hidden comments."); text.setWhitespaceMode(WhitespaceMode.PARAGRAPHS); add(text); textComment.setRows(5); WFieldLayout layout = new WFieldLayout(); WField field = layout.addField("Enter text to be hidden as a comment", textComment); field.setInputWidth(100); add(layout); WButton button = new WButton("Submit"); button.setAction(new Action() { @Override public void execute(final ActionEvent event) { comment2.setText(textComment.getText()); } }); add(comment1); add(comment2); add(button); }
selectionText.setWhitespaceMode(WStyledText.WhitespaceMode.PRESERVE);
info.setWhitespaceMode(WhitespaceMode.PRESERVE); infoPanel.add(info);
dataOutput.setWhitespaceMode(WStyledText.WhitespaceMode.PRESERVE);
dataOutput.setWhitespaceMode(WStyledText.WhitespaceMode.PRESERVE);
dataOutput.setWhitespaceMode(WStyledText.WhitespaceMode.PRESERVE);
selectionText.setWhitespaceMode(WStyledText.WhitespaceMode.PRESERVE); add(new ExplanatoryText("This example shows a simple selection mechanism. The table actions show some variations on how to set up constrained" + " actions. The delete and edit buttons do nothing in this example: they are merely there to show how to wire up different "
public SimplePaginationTableWithSelectablesExample() { selectionText.setWhitespaceMode(WStyledText.WhitespaceMode.PRESERVE); add(wTable);
dataOutput.setWhitespaceMode(WStyledText.WhitespaceMode.PRESERVE); add(dataOutput);
@Test public void testParagraphText() throws IOException, SAXException, XpathException { WStyledText styledText = new WStyledText("abc def"); styledText.setWhitespaceMode(WStyledText.WhitespaceMode.PARAGRAPHS); assertSchemaMatch(styledText); assertXpathEvaluatesTo("abc def", "//ui:text[@type='plain']", styledText);