use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WCheckBoxRenderer method doRender.
/**
* Paints the given WCheckBox.
*
* @param component the WCheckBox to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WCheckBox checkBox = (WCheckBox) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean readOnly = checkBox.isReadOnly();
xml.appendTagOpen(TAG_NAME);
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", checkBox.isHidden(), "true");
xml.appendOptionalAttribute("selected", checkBox.isSelected(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
xml.appendEnd();
return;
}
WComponent submitControl = checkBox.getDefaultSubmitButton();
String submitControlId = submitControl == null ? null : submitControl.getId();
WComponentGroup<WCheckBox> group = checkBox.getGroup();
String groupName = group == null ? null : group.getId();
xml.appendOptionalAttribute("groupName", groupName);
xml.appendOptionalAttribute("disabled", checkBox.isDisabled(), "true");
xml.appendOptionalAttribute("required", checkBox.isMandatory(), "true");
xml.appendOptionalAttribute("submitOnChange", checkBox.isSubmitOnChange(), "true");
xml.appendOptionalAttribute("toolTip", checkBox.getToolTip());
xml.appendOptionalAttribute("accessibleText", checkBox.getAccessibleText());
xml.appendOptionalAttribute("buttonId", submitControlId);
List<Diagnostic> diags = checkBox.getDiagnostics(Diagnostic.ERROR);
if (diags == null || diags.isEmpty()) {
xml.appendEnd();
return;
}
xml.appendClose();
DiagnosticRenderUtil.renderDiagnostics(checkBox, renderContext);
xml.appendEndTag(TAG_NAME);
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WCollapsibleRenderer method doRender.
/**
* Paints the given WCollapsible.
*
* @param component the WCollapsible to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WCollapsible collapsible = (WCollapsible) component;
XmlStringBuilder xml = renderContext.getWriter();
WComponent content = collapsible.getContent();
boolean collapsed = collapsible.isCollapsed();
xml.appendTagOpen("ui:collapsible");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendAttribute("groupName", collapsible.getGroupName());
xml.appendOptionalAttribute("collapsed", collapsed, "true");
xml.appendOptionalAttribute("hidden", collapsible.isHidden(), "true");
switch(collapsible.getMode()) {
case CLIENT:
xml.appendAttribute("mode", "client");
break;
case LAZY:
xml.appendAttribute("mode", "lazy");
break;
case EAGER:
xml.appendAttribute("mode", "eager");
break;
case DYNAMIC:
xml.appendAttribute("mode", "dynamic");
break;
case SERVER:
xml.appendAttribute("mode", "server");
break;
default:
throw new SystemException("Unknown collapsible mode: " + collapsible.getMode());
}
HeadingLevel level = collapsible.getHeadingLevel();
if (level != null) {
xml.appendAttribute("level", level.getLevel());
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(collapsible, renderContext);
// Label
collapsible.getDecoratedLabel().paint(renderContext);
// Content
xml.appendTagOpen("ui:content");
xml.appendAttribute("id", component.getId() + "-content");
xml.appendClose();
// Render content if not EAGER Mode or is EAGER and is the current AJAX trigger
if (CollapsibleMode.EAGER != collapsible.getMode() || AjaxHelper.isCurrentAjaxTrigger(collapsible)) {
// Visibility of content set in prepare paint
content.paint(renderContext);
}
xml.appendEndTag("ui:content");
xml.appendEndTag("ui:collapsible");
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WCollapsibleToggleRenderer method doRender.
/**
* Paints the given WCollapsibleToggle.
*
* @param component the WCollapsibleToggle to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WCollapsibleToggle toggle = (WCollapsibleToggle) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:collapsibletoggle");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendAttribute("groupName", toggle.getGroupName());
xml.appendEnd();
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WColumnRenderer method doRender.
/**
* Paints the given WButton.
*
* @param component the WColumn to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WColumn col = (WColumn) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:column");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
int width = col.getWidth();
xml.appendOptionalAttribute("width", width > 0, width);
switch(col.getAlignment()) {
case LEFT:
// left is assumed if omitted
break;
case RIGHT:
xml.appendAttribute("align", "right");
break;
case CENTER:
xml.appendAttribute("align", "center");
break;
default:
throw new IllegalArgumentException("Invalid alignment: " + col.getAlignment());
}
xml.appendClose();
// Paint column contents
paintChildren(col, renderContext);
xml.appendEndTag("ui:column");
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WComponentGroupRenderer method doRender.
/**
* Paints the given WComponentGroup.
*
* @param component the WComponentGroup to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WComponentGroup group = (WComponentGroup) component;
XmlStringBuilder xml = renderContext.getWriter();
List<WComponent> components = group.getComponents();
if (components != null && !components.isEmpty()) {
xml.appendTagOpen("ui:componentGroup");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendClose();
for (WComponent comp : components) {
xml.appendTagOpen("ui:component");
xml.appendAttribute("id", comp.getId());
xml.appendEnd();
}
xml.appendEndTag("ui:componentGroup");
}
}
Aggregations