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