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