Search in sources :

Example 1 with WHiddenComment

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

the class WHiddenCommentRenderer method doRender.

/**
 * Paints the given WHiddenComment.
 *
 * @param component the WHiddenComment to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WHiddenComment hiddenComponent = (WHiddenComment) component;
    XmlStringBuilder xml = renderContext.getWriter();
    String hiddenText = hiddenComponent.getText();
    if (!Util.empty(hiddenText)) {
        xml.appendTag("ui:comment");
        xml.appendEscaped(hiddenText);
        xml.appendEndTag("ui:comment");
    }
}
Also used : WHiddenComment(com.github.bordertech.wcomponents.WHiddenComment) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 2 with WHiddenComment

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

the class WHiddenCommentRenderer_Test method testRendererCorrectlyConfigured.

/**
 * Test the Layout is correctly configured.
 */
@Test
public void testRendererCorrectlyConfigured() {
    WHiddenComment hiddenComment = new WHiddenComment("comment");
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(hiddenComment) instanceof WHiddenCommentRenderer);
}
Also used : WHiddenComment(com.github.bordertech.wcomponents.WHiddenComment) Test(org.junit.Test)

Example 3 with WHiddenComment

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

the class WHiddenCommentRenderer_Test method testEncodedComment.

@Test
public void testEncodedComment() throws IOException, SAXException, XpathException {
    String textString = "test <br/> > <";
    WHiddenComment comment = new WHiddenComment(textString);
    // Validate
    assertSchemaMatch(comment);
    assertXpathEvaluatesTo(textString, COMMENT_XPATH, comment);
}
Also used : WHiddenComment(com.github.bordertech.wcomponents.WHiddenComment) Test(org.junit.Test)

Example 4 with WHiddenComment

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

the class WHiddenCommentRenderer_Test method testXssEscaping.

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

Example 5 with WHiddenComment

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

the class WHiddenCommentRenderer_Test method testMultipleComments.

@Test
public void testMultipleComments() throws IOException, SAXException, XpathException {
    String textString1 = "test comment1";
    String textString2 = "test comment2";
    WHiddenComment comment1 = new WHiddenComment(textString1);
    WHiddenComment comment2 = new WHiddenComment(textString2);
    WPanel panel = new WPanel();
    panel.add(comment1);
    panel.add(comment2);
    // Validate
    assertSchemaMatch(panel);
    assertXpathEvaluatesTo("2", "count(//ui:comment)", panel);
}
Also used : WHiddenComment(com.github.bordertech.wcomponents.WHiddenComment) WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Aggregations

WHiddenComment (com.github.bordertech.wcomponents.WHiddenComment)6 Test (org.junit.Test)5 WPanel (com.github.bordertech.wcomponents.WPanel)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1