Search in sources :

Example 16 with XmlStringBuilder

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

the class WMessageBoxRenderer method doRender.

/**
 * Paints the given WMessageBox.
 *
 * @param component the WMessageBox to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WMessageBox messageBox = (WMessageBox) component;
    XmlStringBuilder xml = renderContext.getWriter();
    if (messageBox.hasMessages()) {
        xml.appendTagOpen("ui:messagebox");
        xml.appendAttribute("id", component.getId());
        xml.appendOptionalAttribute("class", component.getHtmlClass());
        xml.appendOptionalAttribute("track", component.isTracking(), "true");
        switch(messageBox.getType()) {
            case SUCCESS:
                xml.appendOptionalAttribute("type", "success");
                break;
            case INFO:
                xml.appendOptionalAttribute("type", "info");
                break;
            case WARN:
                xml.appendOptionalAttribute("type", "warn");
                break;
            case ERROR:
            default:
                xml.appendOptionalAttribute("type", "error");
                break;
        }
        xml.appendOptionalAttribute("title", messageBox.getTitleText());
        xml.appendClose();
        for (String message : messageBox.getMessages()) {
            xml.appendTag("ui:message");
            xml.print(message);
            xml.appendEndTag("ui:message");
        }
        xml.appendEndTag("ui:messagebox");
    }
}
Also used : WMessageBox(com.github.bordertech.wcomponents.WMessageBox) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 17 with XmlStringBuilder

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

the class WMultiDropdownRenderer method doRender.

/**
 * Paints the given WMultiDropdown.
 *
 * @param component the WMultiDropdown to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WMultiDropdown dropdown = (WMultiDropdown) component;
    XmlStringBuilder xml = renderContext.getWriter();
    String dataKey = dropdown.getListCacheKey();
    boolean readOnly = dropdown.isReadOnly();
    xml.appendTagOpen("ui:multidropdown");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    xml.appendOptionalAttribute("hidden", dropdown.isHidden(), "true");
    if (readOnly) {
        xml.appendAttribute("readOnly", "true");
    } else {
        xml.appendOptionalAttribute("data", dataKey != null && !readOnly, dataKey);
        xml.appendOptionalAttribute("disabled", dropdown.isDisabled(), "true");
        xml.appendOptionalAttribute("required", dropdown.isMandatory(), "true");
        xml.appendOptionalAttribute("submitOnChange", dropdown.isSubmitOnChange(), "true");
        xml.appendOptionalAttribute("toolTip", component.getToolTip());
        xml.appendOptionalAttribute("accessibleText", component.getAccessibleText());
        int min = dropdown.getMinSelect();
        int max = dropdown.getMaxSelect();
        xml.appendOptionalAttribute("min", min > 0, min);
        xml.appendOptionalAttribute("max", max > 0, max);
        xml.appendOptionalAttribute("title", I18nUtilities.format(null, InternalMessages.DEFAULT_MULTI_FORM_COMPONENT_TIP));
    }
    xml.appendClose();
    // Options
    List<?> options = dropdown.getOptions();
    boolean renderSelectionsOnly = dropdown.isReadOnly() || dataKey != null;
    if (options != null) {
        int optionIndex = 0;
        List<?> selections = dropdown.getSelected();
        for (Object option : options) {
            if (option instanceof OptionGroup) {
                xml.appendTagOpen("ui:optgroup");
                xml.appendAttribute("label", ((OptionGroup) option).getDesc());
                xml.appendClose();
                for (Object nestedOption : ((OptionGroup) option).getOptions()) {
                    renderOption(dropdown, nestedOption, optionIndex++, xml, selections, renderSelectionsOnly);
                }
                xml.appendEndTag("ui:optgroup");
            } else {
                renderOption(dropdown, option, optionIndex++, xml, selections, renderSelectionsOnly);
            }
        }
    }
    if (!readOnly) {
        DiagnosticRenderUtil.renderDiagnostics(dropdown, renderContext);
    }
    // End tag
    xml.appendEndTag("ui:multidropdown");
}
Also used : OptionGroup(com.github.bordertech.wcomponents.OptionGroup) WMultiDropdown(com.github.bordertech.wcomponents.WMultiDropdown) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 18 with XmlStringBuilder

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

the class WMultiTextFieldRenderer method doRender.

/**
 * Paints the given WMultiTextField.
 *
 * @param component the WMultiTextField to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WMultiTextField textField = (WMultiTextField) component;
    XmlStringBuilder xml = renderContext.getWriter();
    boolean readOnly = textField.isReadOnly();
    String[] values = textField.getTextInputs();
    xml.appendTagOpen("ui:multitextfield");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    xml.appendOptionalAttribute("hidden", textField.isHidden(), "true");
    if (readOnly) {
        xml.appendAttribute("readOnly", "true");
    } else {
        int cols = textField.getColumns();
        int minLength = textField.getMinLength();
        int maxLength = textField.getMaxLength();
        int maxInputs = textField.getMaxInputs();
        String pattern = textField.getPattern();
        xml.appendOptionalAttribute("disabled", textField.isDisabled(), "true");
        xml.appendOptionalAttribute("required", textField.isMandatory(), "true");
        xml.appendOptionalAttribute("toolTip", textField.getToolTip());
        xml.appendOptionalAttribute("accessibleText", textField.getAccessibleText());
        xml.appendOptionalAttribute("size", cols > 0, cols);
        xml.appendOptionalAttribute("minLength", minLength > 0, minLength);
        xml.appendOptionalAttribute("maxLength", maxLength > 0, maxLength);
        xml.appendOptionalAttribute("max", maxInputs > 0, maxInputs);
        xml.appendOptionalAttribute("pattern", !Util.empty(pattern), pattern);
        xml.appendOptionalAttribute("placeholder", HtmlRenderUtil.getEffectivePlaceholder(textField));
        xml.appendOptionalAttribute("title", I18nUtilities.format(null, InternalMessages.DEFAULT_MULTI_FORM_COMPONENT_TIP));
    }
    xml.appendClose();
    if (values != null) {
        for (String value : values) {
            xml.appendTag("ui:value");
            xml.appendEscaped(value);
            xml.appendEndTag("ui:value");
        }
    }
    if (!readOnly) {
        DiagnosticRenderUtil.renderDiagnostics(textField, renderContext);
    }
    xml.appendEndTag("ui:multitextfield");
}
Also used : WMultiTextField(com.github.bordertech.wcomponents.WMultiTextField) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 19 with XmlStringBuilder

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

the class WPopupRenderer method doRender.

/**
 * Paints the given WPopup.
 *
 * @param component the WPopup to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WPopup popup = (WPopup) component;
    XmlStringBuilder xml = renderContext.getWriter();
    int width = popup.getWidth();
    int height = popup.getHeight();
    String targetWindow = popup.getTargetWindow();
    xml.appendTagOpen("ui:popup");
    xml.appendUrlAttribute("url", popup.getUrl());
    xml.appendOptionalAttribute("width", width > 0, width);
    xml.appendOptionalAttribute("height", height > 0, height);
    xml.appendOptionalAttribute("resizable", popup.isResizable(), "true");
    xml.appendOptionalAttribute("showScrollbars", popup.isScrollable(), "true");
    xml.appendOptionalAttribute("targetWindow", !Util.empty(targetWindow), targetWindow);
    xml.appendClose();
    xml.appendEndTag("ui:popup");
}
Also used : WPopup(com.github.bordertech.wcomponents.WPopup) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 20 with XmlStringBuilder

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

the class WRepeaterRenderer method doRender.

/**
 * Paints the given WText.
 *
 * @param component the WText to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WRepeater repeater = (WRepeater) component;
    XmlStringBuilder xml = renderContext.getWriter();
    xml.appendTagOpen("ui:panel");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    xml.appendClose();
    xml.appendTag("ui:content");
    paintRows(repeater, renderContext);
    xml.appendEndTag("ui:content");
    xml.appendEndTag("ui:panel");
}
Also used : WRepeater(com.github.bordertech.wcomponents.WRepeater) 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