Search in sources :

Example 36 with WText

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

the class WCollapsibleRenderer_Test method testDoRenderLazyCollapse.

@Test
public void testDoRenderLazyCollapse() throws IOException, SAXException, XpathException {
    WCollapsible collapsible = new WCollapsible(new WText(COLLAPSIBLE_CONTENT), COLLAPSIBLE_HEADING, WCollapsible.CollapsibleMode.LAZY);
    assertSchemaMatch(collapsible);
    assertXpathEvaluatesTo("lazy", "//ui:collapsible/@mode", collapsible);
    assertRenderContentCorrectly(collapsible, false, true);
}
Also used : WCollapsible(com.github.bordertech.wcomponents.WCollapsible) WText(com.github.bordertech.wcomponents.WText) Test(org.junit.Test)

Example 37 with WText

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

the class WCollapsibleRenderer_Test method testRenderedWithHeadingLevel.

@Test
public void testRenderedWithHeadingLevel() throws IOException, SAXException, XpathException {
    WCollapsible collapsible = new WCollapsible(new WText(COLLAPSIBLE_CONTENT), COLLAPSIBLE_HEADING, WCollapsible.CollapsibleMode.EAGER);
    assertSchemaMatch(collapsible);
    assertXpathNotExists("//ui:collapsible/@level", collapsible);
    // Set level
    collapsible.setHeadingLevel(HeadingLevel.H1);
    assertSchemaMatch(collapsible);
    assertXpathEvaluatesTo("1", "//ui:collapsible/@level", collapsible);
}
Also used : WCollapsible(com.github.bordertech.wcomponents.WCollapsible) WText(com.github.bordertech.wcomponents.WText) Test(org.junit.Test)

Example 38 with WText

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

the class WCollapsibleRenderer_Test method testDoRenderDynamicCollapse.

@Test
public void testDoRenderDynamicCollapse() throws IOException, SAXException, XpathException {
    WCollapsible collapsible = new WCollapsible(new WText(COLLAPSIBLE_CONTENT), COLLAPSIBLE_HEADING, WCollapsible.CollapsibleMode.DYNAMIC);
    assertSchemaMatch(collapsible);
    assertXpathEvaluatesTo("dynamic", "//ui:collapsible/@mode", collapsible);
    assertRenderContentCorrectly(collapsible, false, true);
}
Also used : WCollapsible(com.github.bordertech.wcomponents.WCollapsible) WText(com.github.bordertech.wcomponents.WText) Test(org.junit.Test)

Example 39 with WText

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

the class WTextRenderer method doRender.

/**
 * Paints the given WText.
 *
 * @param component the WText to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WText text = (WText) component;
    XmlStringBuilder xml = renderContext.getWriter();
    String textString = text.getText();
    if (textString != null) {
        if (text.isEncodeText()) {
            xml.print(WebUtilities.encode(textString));
        } else {
            // If we are outputting unencoded content it must be XML valid.
            xml.print(HtmlToXMLUtil.unescapeToXML(textString));
        }
    }
}
Also used : WText(com.github.bordertech.wcomponents.WText) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 40 with WText

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

the class WTextRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WText text = new WText();
    text.setText(getInvalidCharSequence());
    assertSafeContent(text);
    text.setText(getMaliciousContent());
    assertSafeContent(text);
}
Also used : WText(com.github.bordertech.wcomponents.WText) Test(org.junit.Test)

Aggregations

WText (com.github.bordertech.wcomponents.WText)100 Test (org.junit.Test)63 WPanel (com.github.bordertech.wcomponents.WPanel)18 WCollapsible (com.github.bordertech.wcomponents.WCollapsible)10 WDecoratedLabel (com.github.bordertech.wcomponents.WDecoratedLabel)10 WHeading (com.github.bordertech.wcomponents.WHeading)10 UIContext (com.github.bordertech.wcomponents.UIContext)9 WTabSet (com.github.bordertech.wcomponents.WTabSet)7 DefaultWComponent (com.github.bordertech.wcomponents.DefaultWComponent)6 WList (com.github.bordertech.wcomponents.WList)6 WebXmlRenderContext (com.github.bordertech.wcomponents.servlet.WebXmlRenderContext)6 MockResponse (com.github.bordertech.wcomponents.util.mock.MockResponse)6 MockServletConfig (com.github.bordertech.wcomponents.util.mock.servlet.MockServletConfig)6 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)5 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)5 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)5 WImage (com.github.bordertech.wcomponents.WImage)5 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)5 WTextField (com.github.bordertech.wcomponents.WTextField)5 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)5