Search in sources :

Example 16 with WText

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

the class FlowLayoutExample method addBoxesWithDiffContent.

/**
 * Adds a set of boxes to the given panel.
 *
 * @param panel the panel to add the boxes to.
 * @param amount the number of boxes to add.
 */
private static void addBoxesWithDiffContent(final WPanel panel, final int amount) {
    for (int i = 1; i <= amount; i++) {
        WPanel content = new WPanel(WPanel.Type.BOX);
        content.setLayout(new FlowLayout(FlowLayout.VERTICAL, Size.SMALL));
        for (int j = 1; j <= i; j++) {
            content.add(new WText(Integer.toString(i)));
        }
        panel.add(content);
    }
}
Also used : FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) WText(com.github.bordertech.wcomponents.WText) WPanel(com.github.bordertech.wcomponents.WPanel)

Example 17 with WText

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

the class FlowLayoutExample method addBoxes.

/**
 * Adds a set of boxes to the given panel.
 *
 * @param panel the panel to add the boxes to.
 * @param amount the number of boxes to add.
 */
private static void addBoxes(final WPanel panel, final int amount) {
    for (int i = 1; i <= amount; i++) {
        WPanel box = new WPanel(WPanel.Type.BOX);
        box.add(new WText(Integer.toString(i)));
        panel.add(box);
    }
}
Also used : WText(com.github.bordertech.wcomponents.WText) WPanel(com.github.bordertech.wcomponents.WPanel)

Example 18 with WText

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

the class WFigureRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WFigure figure = new WFigure(new WText(), "");
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(figure) instanceof WFigureRenderer);
}
Also used : WFigure(com.github.bordertech.wcomponents.WFigure) WText(com.github.bordertech.wcomponents.WText) Test(org.junit.Test)

Example 19 with WText

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

the class WFigureRenderer_Test method testXssEscaping.

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

Example 20 with WText

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

the class WFigureRenderer_Test method testRenderedEagerMode.

@Test
public void testRenderedEagerMode() throws IOException, SAXException, XpathException {
    WFigure figure = new WFigure(new WText(FIGURE_CONTENT), FIGURE_HEADING);
    figure.setMode(FigureMode.EAGER);
    UIContext uic = createUIContext();
    uic.setUI(new DefaultWComponent());
    setActiveContext(uic);
    // The figure's content should NOT be rendered
    assertSchemaMatch(figure);
    assertXpathEvaluatesTo("", "//ui:figure/@type", figure);
    assertXpathEvaluatesTo("", "//ui:figure/@hidden", figure);
    assertXpathEvaluatesTo("eager", "//ui:figure/@mode", figure);
    assertXpathEvaluatesTo("", "//ui:figure/ui:content", figure);
    try {
        // Figure is the AJAX Trigger, content should be rendered
        AjaxOperation operation = new AjaxOperation(figure.getId(), figure.getId());
        AjaxHelper.setCurrentOperationDetails(operation, null);
        assertSchemaMatch(figure);
        assertXpathEvaluatesTo("", "//ui:figure/@type", figure);
        assertXpathEvaluatesTo("", "//ui:figure/@hidden", figure);
        assertXpathEvaluatesTo("eager", "//ui:figure/@mode", figure);
        assertXpathEvaluatesTo(FIGURE_CONTENT, "//ui:figure/ui:content", figure);
    } finally {
        AjaxHelper.clearCurrentOperationDetails();
    }
}
Also used : WFigure(com.github.bordertech.wcomponents.WFigure) AjaxOperation(com.github.bordertech.wcomponents.AjaxOperation) WText(com.github.bordertech.wcomponents.WText) UIContext(com.github.bordertech.wcomponents.UIContext) DefaultWComponent(com.github.bordertech.wcomponents.DefaultWComponent) 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