Search in sources :

Example 1 with SectionMode

use of com.github.bordertech.wcomponents.WSection.SectionMode in project wcomponents by BorderTech.

the class WSectionRenderer method doRender.

/**
 * Paints the given WSection.
 *
 * @param component the WSection to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WSection section = (WSection) component;
    XmlStringBuilder xml = renderContext.getWriter();
    boolean renderChildren = isRenderContent(section);
    xml.appendTagOpen("ui:section");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    if (SectionMode.LAZY.equals(section.getMode())) {
        xml.appendOptionalAttribute("hidden", !renderChildren, "true");
    } else {
        xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
    }
    SectionMode mode = section.getMode();
    if (mode != null) {
        switch(mode) {
            case LAZY:
                xml.appendAttribute("mode", "lazy");
                break;
            case EAGER:
                xml.appendAttribute("mode", "eager");
                break;
            default:
                throw new SystemException("Unknown section mode: " + section.getMode());
        }
    }
    xml.appendClose();
    // Render margin
    MarginRendererUtil.renderMargin(section, renderContext);
    if (renderChildren) {
        // Label
        section.getDecoratedLabel().paint(renderContext);
        // Content
        section.getContent().paint(renderContext);
    }
    xml.appendEndTag("ui:section");
}
Also used : WSection(com.github.bordertech.wcomponents.WSection) SectionMode(com.github.bordertech.wcomponents.WSection.SectionMode) SystemException(com.github.bordertech.wcomponents.util.SystemException) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Aggregations

WSection (com.github.bordertech.wcomponents.WSection)1 SectionMode (com.github.bordertech.wcomponents.WSection.SectionMode)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1 SystemException (com.github.bordertech.wcomponents.util.SystemException)1