Search in sources :

Example 1 with State

use of com.github.bordertech.wcomponents.WSelectToggle.State in project wcomponents by BorderTech.

the class WSelectToggleRenderer method doRender.

/**
 * Paints the given WSelectToggle.
 *
 * @param component the WSelectToggle to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WSelectToggle toggle = (WSelectToggle) component;
    XmlStringBuilder xml = renderContext.getWriter();
    xml.appendTagOpen("ui:selecttoggle");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    State state = toggle.getState();
    if (State.ALL.equals(state)) {
        xml.appendAttribute("selected", "all");
    } else if (State.NONE.equals(state)) {
        xml.appendAttribute("selected", "none");
    } else {
        xml.appendAttribute("selected", "some");
    }
    xml.appendOptionalAttribute("disabled", toggle.isDisabled(), "true");
    xml.appendAttribute("target", toggle.getTarget().getId());
    xml.appendAttribute("renderAs", toggle.isRenderAsText() ? "text" : "control");
    xml.appendOptionalAttribute("roundTrip", !toggle.isClientSide(), "true");
    xml.appendEnd();
}
Also used : State(com.github.bordertech.wcomponents.WSelectToggle.State) WSelectToggle(com.github.bordertech.wcomponents.WSelectToggle) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Aggregations

WSelectToggle (com.github.bordertech.wcomponents.WSelectToggle)1 State (com.github.bordertech.wcomponents.WSelectToggle.State)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1