Search in sources :

Example 1 with MultiInputComponent

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

the class WLabelRenderer method doRender.

/**
 * Paints the given {@link WLabel}.
 *
 * @param component the WLabel to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WLabel label = (WLabel) component;
    XmlStringBuilder xml = renderContext.getWriter();
    xml.appendTagOpen("ui:label");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    xml.appendOptionalAttribute("for", label.getLabelFor());
    WComponent what = label.getForComponent();
    String whatFor = null;
    if (what instanceof MultiInputComponent) {
        whatFor = "group";
    } else if (what instanceof Labelable) {
        whatFor = "input";
    }
    boolean isReadOnly = ((what instanceof Input) && ((Input) what).isReadOnly()) || (what instanceof WRadioButton && ((WRadioButton) what).isReadOnly());
    boolean isMandatory = (what instanceof Input) && ((Input) what).isMandatory();
    xml.appendOptionalAttribute("what", whatFor);
    xml.appendOptionalAttribute("readonly", isReadOnly, "true");
    xml.appendOptionalAttribute("required", isMandatory, "true");
    xml.appendOptionalAttribute("hiddencomponent", (what != null && what.isHidden()), "true");
    xml.appendOptionalAttribute("hint", label.getHint());
    xml.appendOptionalAttribute("accessKey", Util.upperCase(label.getAccessKeyAsString()));
    xml.appendOptionalAttribute("hidden", label.isHidden(), "true");
    xml.appendOptionalAttribute("toolTip", label.getToolTip());
    xml.appendOptionalAttribute("accessibleText", label.getAccessibleText());
    xml.appendClose();
    xml.append(label.getText(), label.isEncodeText());
    paintChildren(label, renderContext);
    xml.appendEndTag("ui:label");
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) Labelable(com.github.bordertech.wcomponents.Labelable) MultiInputComponent(com.github.bordertech.wcomponents.MultiInputComponent) Input(com.github.bordertech.wcomponents.Input) WRadioButton(com.github.bordertech.wcomponents.WRadioButton) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder) WLabel(com.github.bordertech.wcomponents.WLabel)

Aggregations

Input (com.github.bordertech.wcomponents.Input)1 Labelable (com.github.bordertech.wcomponents.Labelable)1 MultiInputComponent (com.github.bordertech.wcomponents.MultiInputComponent)1 WComponent (com.github.bordertech.wcomponents.WComponent)1 WLabel (com.github.bordertech.wcomponents.WLabel)1 WRadioButton (com.github.bordertech.wcomponents.WRadioButton)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1