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);
}
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);
}
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);
}
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));
}
}
}
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);
}
Aggregations