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");
}
}
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");
}
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");
}
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");
}
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");
}
Aggregations