Search in sources :

Example 61 with WPanel

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

the class WLinkRenderer_Test method testDoPaintWithAction.

@Test
public void testDoPaintWithAction() throws IOException, SAXException, XpathException {
    WContainer root = new WContainer();
    WLink link = new WLink("test", "http://test");
    WPanel target1 = new WPanel();
    WPanel target2 = new WPanel();
    root.add(link);
    root.add(target1);
    root.add(target2);
    // No Targets (target itself)
    link.setAction(new TestAction());
    assertSchemaMatch(root);
    assertXpathEvaluatesTo(link.getId(), "//ui:ajaxtrigger/@triggerId", root);
    assertXpathEvaluatesTo("1", "count(//ui:ajaxtrigger/ui:ajaxtargetid)", root);
    assertXpathEvaluatesTo(link.getId(), "//ui:ajaxtrigger/ui:ajaxtargetid[1]/@targetId", root);
    // With Targets
    link.setAction(new TestAction(), target1, target2);
    assertSchemaMatch(root);
    assertXpathEvaluatesTo(link.getId(), "//ui:ajaxtrigger/@triggerId", root);
    assertXpathEvaluatesTo("2", "count(//ui:ajaxtrigger/ui:ajaxtargetid)", root);
    assertXpathEvaluatesTo(target1.getId(), "//ui:ajaxtrigger/ui:ajaxtargetid[1]/@targetId", root);
    assertXpathEvaluatesTo(target2.getId(), "//ui:ajaxtrigger/ui:ajaxtargetid[2]/@targetId", root);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WPanel(com.github.bordertech.wcomponents.WPanel) WLink(com.github.bordertech.wcomponents.WLink) TestAction(com.github.bordertech.wcomponents.TestAction) Test(org.junit.Test)

Example 62 with WPanel

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

the class WPanelRenderer_Test method testRenderedLazyModePanel.

@Test
public void testRenderedLazyModePanel() throws IOException, SAXException, XpathException {
    String content = "TEST CONTENT";
    WPanel panel = new WPanel();
    panel.setMode(PanelMode.LAZY);
    panel.add(new WText(content));
    // Content NOT Hidden
    assertSchemaMatch(panel);
    // If not hidden, then the panel's content should be rendered
    assertXpathEvaluatesTo("", "//ui:panel/@type", panel);
    assertXpathEvaluatesTo("", "//ui:panel/@hidden", panel);
    assertXpathEvaluatesTo("lazy", "//ui:panel/@mode", panel);
    assertXpathEvaluatesTo(content, "//ui:panel/ui:content", panel);
    // Content Hidden
    // Create User Context with UI component
    UIContext uic = createUIContext();
    uic.setUI(new DefaultWComponent());
    setActiveContext(uic);
    setFlag(panel, ComponentModel.HIDE_FLAG, true);
    assertSchemaMatch(panel);
    // If hidden, then the panel's content should NOT be rendered
    assertXpathEvaluatesTo("", "//ui:panel/@type", panel);
    assertXpathEvaluatesTo("true", "//ui:panel/@hidden", panel);
    assertXpathEvaluatesTo("lazy", "//ui:panel/@mode", panel);
    assertXpathEvaluatesTo("", "//ui:panel/ui:content", panel);
}
Also used : WText(com.github.bordertech.wcomponents.WText) UIContext(com.github.bordertech.wcomponents.UIContext) WPanel(com.github.bordertech.wcomponents.WPanel) DefaultWComponent(com.github.bordertech.wcomponents.DefaultWComponent) Test(org.junit.Test)

Example 63 with WPanel

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

the class WPanelRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WPanel panel = new WPanel();
    panel.setTitleText(getMaliciousAttribute("ui:panel"));
    assertSafeContent(panel);
}
Also used : WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Example 64 with WPanel

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

the class WPanelRenderer_Test method testRenderedFormatWithAccessKey.

@Test
public void testRenderedFormatWithAccessKey() throws IOException, SAXException, XpathException {
    WPanel panel = new WPanel();
    assertXpathNotExists("//ui:panel/@accessKey", panel);
    panel.setAccessKey('x');
    assertSchemaMatch(panel);
    assertXpathEvaluatesTo("X", "//ui:panel/@accessKey", panel);
}
Also used : WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Example 65 with WPanel

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

the class WPanelRenderer_Test method testRenderAllPanelTypes.

@Test
public void testRenderAllPanelTypes() throws IOException, SAXException, XpathException {
    // Tests that all panel types are schema valid
    for (WPanel.Type type : WPanel.Type.values()) {
        WPanel panel = new WPanel(type);
        WButton button = new WButton("submit");
        panel.add(button);
        panel.setDefaultSubmitButton(button);
        panel.setTitleText("Panel title");
        assertSchemaMatch(panel);
    }
}
Also used : WPanel(com.github.bordertech.wcomponents.WPanel) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Aggregations

WPanel (com.github.bordertech.wcomponents.WPanel)77 Test (org.junit.Test)39 WHeading (com.github.bordertech.wcomponents.WHeading)17 WText (com.github.bordertech.wcomponents.WText)17 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)16 WButton (com.github.bordertech.wcomponents.WButton)13 ColumnLayout (com.github.bordertech.wcomponents.layout.ColumnLayout)10 WContainer (com.github.bordertech.wcomponents.WContainer)9 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)9 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)8 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)8 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)7 WLabel (com.github.bordertech.wcomponents.WLabel)7 Action (com.github.bordertech.wcomponents.Action)6 WTextField (com.github.bordertech.wcomponents.WTextField)6 ArrayList (java.util.ArrayList)6 Size (com.github.bordertech.wcomponents.Size)5 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)5 BorderLayout (com.github.bordertech.wcomponents.layout.BorderLayout)5 Alignment (com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment)5