Search in sources :

Example 86 with XmlStringBuilder

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

the class WPhoneNumberFieldRenderer method doRender.

/**
 * Paints the given WPhoneNumberField.
 *
 * @param component the WPhoneNumberField to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WPhoneNumberField field = (WPhoneNumberField) component;
    XmlStringBuilder xml = renderContext.getWriter();
    boolean readOnly = field.isReadOnly();
    xml.appendTagOpen("ui:phonenumberfield");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
    if (readOnly) {
        xml.appendAttribute("readOnly", "true");
    } else {
        int cols = field.getColumns();
        int minLength = field.getMinLength();
        int maxLength = field.getMaxLength();
        String pattern = field.getPattern();
        WSuggestions suggestions = field.getSuggestions();
        String suggestionsId = suggestions == null ? null : suggestions.getId();
        WComponent submitControl = field.getDefaultSubmitButton();
        String submitControlId = submitControl == null ? null : submitControl.getId();
        xml.appendOptionalAttribute("disabled", field.isDisabled(), "true");
        xml.appendOptionalAttribute("required", field.isMandatory(), "true");
        xml.appendOptionalAttribute("minLength", minLength > 0, minLength);
        xml.appendOptionalAttribute("maxLength", maxLength > 0, maxLength);
        xml.appendOptionalAttribute("toolTip", field.getToolTip());
        xml.appendOptionalAttribute("accessibleText", field.getAccessibleText());
        xml.appendOptionalAttribute("size", cols > 0, cols);
        xml.appendOptionalAttribute("buttonId", submitControlId);
        xml.appendOptionalAttribute("pattern", !Util.empty(pattern), pattern);
        xml.appendOptionalAttribute("list", suggestionsId);
        xml.appendOptionalAttribute("placeholder", HtmlRenderUtil.getEffectivePlaceholder(field));
    }
    xml.appendClose();
    xml.appendEscaped(field.getText());
    if (!readOnly) {
        DiagnosticRenderUtil.renderDiagnostics(field, renderContext);
    }
    xml.appendEndTag("ui:phonenumberfield");
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) WPhoneNumberField(com.github.bordertech.wcomponents.WPhoneNumberField) WSuggestions(com.github.bordertech.wcomponents.WSuggestions) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 87 with XmlStringBuilder

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

the class WProgressBarRenderer method doRender.

/**
 * Paints the given WProgressBar.
 *
 * @param component the WProgressBar to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WProgressBar progressBar = (WProgressBar) component;
    XmlStringBuilder xml = renderContext.getWriter();
    xml.appendTagOpen("html:progress");
    xml.appendAttribute("id", component.getId());
    xml.appendAttribute("class", getHtmlClass(progressBar));
    xml.appendOptionalAttribute("hidden", progressBar.isHidden(), "hidden");
    xml.appendOptionalAttribute("title", progressBar.getToolTip());
    xml.appendOptionalAttribute("aria-label", progressBar.getAccessibleText());
    xml.appendAttribute("value", progressBar.getValue());
    xml.appendOptionalAttribute("max", progressBar.getMax() > 0, progressBar.getMax());
    xml.appendClose();
    xml.appendEndTag("html:progress");
}
Also used : WProgressBar(com.github.bordertech.wcomponents.WProgressBar) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 88 with XmlStringBuilder

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

the class WRadioButtonRenderer method doRender.

/**
 * Paints the given WRadioButton.
 *
 * @param component the WRadioButton to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WRadioButton button = (WRadioButton) component;
    XmlStringBuilder xml = renderContext.getWriter();
    boolean readOnly = button.isReadOnly();
    String value = button.getValue();
    xml.appendTagOpen("ui:radiobutton");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    xml.appendOptionalAttribute("hidden", button.isHidden(), "true");
    xml.appendAttribute("groupName", button.getGroupName());
    xml.appendAttribute("value", WebUtilities.encode(value));
    if (readOnly) {
        xml.appendAttribute("readOnly", "true");
    } else {
        xml.appendOptionalAttribute("disabled", button.isDisabled(), "true");
        xml.appendOptionalAttribute("required", button.isMandatory(), "true");
        xml.appendOptionalAttribute("submitOnChange", button.isSubmitOnChange(), "true");
        xml.appendOptionalAttribute("toolTip", button.getToolTip());
        xml.appendOptionalAttribute("accessibleText", button.getAccessibleText());
        // Check for null option (ie null or empty). Match isEmpty() logic.
        boolean isNull = value == null ? true : (value.length() == 0);
        xml.appendOptionalAttribute("isNull", isNull, "true");
    }
    xml.appendOptionalAttribute("selected", button.isSelected(), "true");
    xml.appendEnd();
}
Also used : WRadioButton(com.github.bordertech.wcomponents.WRadioButton) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 89 with XmlStringBuilder

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

the class WRadioButtonSelectRenderer method doRender.

/**
 * Paints the given WRadioButtonSelect.
 *
 * @param component the WRadioButtonSelect to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WRadioButtonSelect rbSelect = (WRadioButtonSelect) component;
    XmlStringBuilder xml = renderContext.getWriter();
    int cols = rbSelect.getButtonColumns();
    boolean readOnly = rbSelect.isReadOnly();
    xml.appendTagOpen("ui:radiobuttonselect");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    xml.appendOptionalAttribute("hidden", rbSelect.isHidden(), "true");
    if (readOnly) {
        xml.appendAttribute("readOnly", "true");
    } else {
        xml.appendOptionalAttribute("disabled", rbSelect.isDisabled(), "true");
        xml.appendOptionalAttribute("required", rbSelect.isMandatory(), "true");
        xml.appendOptionalAttribute("submitOnChange", rbSelect.isSubmitOnChange(), "true");
        xml.appendOptionalAttribute("toolTip", component.getToolTip());
        xml.appendOptionalAttribute("accessibleText", component.getAccessibleText());
    }
    xml.appendOptionalAttribute("frameless", rbSelect.isFrameless(), "true");
    switch(rbSelect.getButtonLayout()) {
        case COLUMNS:
            xml.appendAttribute("layout", "column");
            xml.appendOptionalAttribute("layoutColumnCount", cols > 0, String.valueOf(cols));
            break;
        case FLAT:
            xml.appendAttribute("layout", "flat");
            break;
        case STACKED:
            xml.appendAttribute("layout", "stacked");
            break;
        default:
            throw new SystemException("Unknown radio button layout: " + rbSelect.getButtonLayout());
    }
    xml.appendClose();
    // Options
    List<?> options = rbSelect.getOptions();
    boolean renderSelectionsOnly = readOnly;
    if (options != null) {
        int optionIndex = 0;
        Object selectedOption = rbSelect.getSelected();
        for (Object option : options) {
            if (option instanceof OptionGroup) {
                throw new SystemException("Option groups not supported in WRadioButtonSelect.");
            } else {
                renderOption(rbSelect, option, optionIndex++, xml, selectedOption, renderSelectionsOnly);
            }
        }
    }
    if (!readOnly) {
        DiagnosticRenderUtil.renderDiagnostics(rbSelect, renderContext);
    }
    xml.appendEndTag("ui:radiobuttonselect");
    if (rbSelect.isAjax()) {
        paintAjax(rbSelect, xml);
    }
}
Also used : OptionGroup(com.github.bordertech.wcomponents.OptionGroup) SystemException(com.github.bordertech.wcomponents.util.SystemException) WRadioButtonSelect(com.github.bordertech.wcomponents.WRadioButtonSelect) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 90 with XmlStringBuilder

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

the class WRowRenderer method doRender.

/**
 * Paints the given WButton.
 *
 * @param component the WRow to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WRow row = (WRow) component;
    XmlStringBuilder xml = renderContext.getWriter();
    int cols = row.getChildCount();
    Size gap = row.getSpace();
    String gapString = gap != null ? gap.toString() : null;
    if (cols > 0) {
        xml.appendTagOpen("ui:row");
        xml.appendAttribute("id", component.getId());
        xml.appendOptionalAttribute("class", component.getHtmlClass());
        xml.appendOptionalAttribute("track", component.isTracking(), "true");
        xml.appendOptionalAttribute("gap", gapString);
        xml.appendClose();
        // Render margin
        MarginRendererUtil.renderMargin(row, renderContext);
        paintChildren(row, renderContext);
        xml.appendEndTag("ui:row");
    }
}
Also used : Size(com.github.bordertech.wcomponents.Size) WRow(com.github.bordertech.wcomponents.WRow) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Aggregations

XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)102 WComponent (com.github.bordertech.wcomponents.WComponent)30 SystemException (com.github.bordertech.wcomponents.util.SystemException)17 Size (com.github.bordertech.wcomponents.Size)8 Diagnostic (com.github.bordertech.wcomponents.validation.Diagnostic)7 OptionGroup (com.github.bordertech.wcomponents.OptionGroup)6 UIContext (com.github.bordertech.wcomponents.UIContext)5 WPanel (com.github.bordertech.wcomponents.WPanel)5 WebXmlRenderContext (com.github.bordertech.wcomponents.servlet.WebXmlRenderContext)5 WButton (com.github.bordertech.wcomponents.WButton)4 WSuggestions (com.github.bordertech.wcomponents.WSuggestions)4 WTable (com.github.bordertech.wcomponents.WTable)4 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)4 ComponentWithContext (com.github.bordertech.wcomponents.ComponentWithContext)3 TableDataModel (com.github.bordertech.wcomponents.TableDataModel)3 TreeTableDataModel (com.github.bordertech.wcomponents.TreeTableDataModel)3 WDataTable (com.github.bordertech.wcomponents.WDataTable)3 WRepeater (com.github.bordertech.wcomponents.WRepeater)3 TableModel (com.github.bordertech.wcomponents.WTable.TableModel)3 AjaxOperation (com.github.bordertech.wcomponents.AjaxOperation)2