use of com.github.bordertech.wcomponents.WTabSet in project wcomponents by BorderTech.
the class WTabSetRenderer method doRender.
/**
* Paints the given WTabSet.
*
* @param component the WTabSet to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WTabSet tabSet = (WTabSet) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:tabset");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendAttribute("type", getTypeAsString(tabSet.getType()));
xml.appendOptionalAttribute("disabled", tabSet.isDisabled(), "true");
xml.appendOptionalAttribute("hidden", tabSet.isHidden(), "true");
xml.appendOptionalAttribute("contentHeight", tabSet.getContentHeight());
xml.appendOptionalAttribute("showHeadOnly", tabSet.isShowHeadOnly(), "true");
xml.appendOptionalAttribute("single", TabSetType.ACCORDION.equals(tabSet.getType()) && tabSet.isSingle(), "true");
if (WTabSet.TabSetType.ACCORDION.equals(tabSet.getType())) {
xml.appendOptionalAttribute("groupName", tabSet.getGroupName());
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(tabSet, renderContext);
paintChildren(tabSet, renderContext);
xml.appendEndTag("ui:tabset");
}
use of com.github.bordertech.wcomponents.WTabSet in project wcomponents by BorderTech.
the class WTabGroupRenderer_Test method wrapTabGroup.
/**
* Tabs can not be used stand-alone, so we must test them through a WTabSet.
*
* @param tabGroup the tab group to wrap
*
* @return wrapped tab group
*/
private WComponent wrapTabGroup(final WTabGroup tabGroup) {
WTabSet tabSet = new WTabSet();
tabSet.add(tabGroup);
return tabSet;
}
use of com.github.bordertech.wcomponents.WTabSet in project wcomponents by BorderTech.
the class WTabRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
WTabSet tabSet = new WTabSet();
WTab tab = tabSet.addTab(new WText("dummy"), getMaliciousContent(), TabMode.CLIENT);
assertSafeContent(tabSet);
tab.setToolTip(getMaliciousAttribute("ui:tab"));
assertSafeContent(tabSet);
tab.setAccessibleText(getMaliciousAttribute("ui:tab"));
assertSafeContent(tabSet);
}
use of com.github.bordertech.wcomponents.WTabSet in project wcomponents by BorderTech.
the class WTabSetRenderer_Test method testSingleAccordian.
@Test
public void testSingleAccordian() throws IOException, SAXException, XpathException {
WTabSet tabSet = new WTabSet(WTabSet.TabSetType.ACCORDION);
tabSet.addTab(new WText("1"), "1", TabMode.CLIENT);
// Default should be single is false (ie not rendered)
assertSchemaMatch(tabSet);
assertXpathEvaluatesTo("", "//ui:tabset/@single", tabSet);
// Default should be single is false (ie not rendered)
tabSet.setSingle(true);
assertSchemaMatch(tabSet);
assertXpathEvaluatesTo("true", "//ui:tabset/@single", tabSet);
}
use of com.github.bordertech.wcomponents.WTabSet in project wcomponents by BorderTech.
the class WTabSetRenderer_Test method testRenderedWithMargins.
@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
WTabSet tabSet = new WTabSet();
tabSet.addTab(new WText("1"), "1", TabMode.CLIENT);
assertXpathNotExists("//ui:tabset/ui:margin", tabSet);
Margin margin = new Margin(0);
tabSet.setMargin(margin);
assertXpathNotExists("//ui:tabset/ui:margin", tabSet);
margin = new Margin(Size.SMALL);
tabSet.setMargin(margin);
assertSchemaMatch(tabSet);
assertXpathEvaluatesTo("sm", "//ui:tabset/ui:margin/@all", tabSet);
assertXpathEvaluatesTo("", "//ui:tabset/ui:margin/@north", tabSet);
assertXpathEvaluatesTo("", "//ui:tabset/ui:margin/@east", tabSet);
assertXpathEvaluatesTo("", "//ui:tabset/ui:margin/@south", tabSet);
assertXpathEvaluatesTo("", "//ui:tabset/ui:margin/@west", tabSet);
}
Aggregations