use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class AjaxInterceptor method paintResponse.
/**
* Paint the ajax response.
*
* @param renderContext the render context
* @param operation the ajax operation
*/
private void paintResponse(final RenderContext renderContext, final AjaxOperation operation) {
WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext;
XmlStringBuilder xml = webRenderContext.getWriter();
// Get trigger's context
ComponentWithContext trigger = AjaxHelper.getCurrentTriggerAndContext();
if (trigger == null) {
throw new SystemException("No context available for trigger " + operation.getTriggerId());
}
for (String targetId : operation.getTargets()) {
ComponentWithContext target;
if (targetId.equals(operation.getTriggerId())) {
target = trigger;
} else {
target = WebUtilities.getComponentById(targetId, true);
if (target == null) {
LOG.warn("Could not find ajax target to render [" + targetId + "]");
continue;
}
}
UIContextHolder.pushContext(target.getContext());
try {
xml.appendTagOpen("ui:ajaxtarget");
xml.appendAttribute("id", targetId);
xml.appendAttribute("action", operation.getAction().getDesc());
xml.appendClose();
target.getComponent().paint(renderContext);
xml.appendEndTag("ui:ajaxtarget");
} finally {
UIContextHolder.popContext();
}
}
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class DebugStructureInterceptor method paint.
/**
* Override paint to render additional information for debugging purposes.
*
* @param renderContext the renderContext to send the output to.
*/
@Override
public void paint(final RenderContext renderContext) {
super.paint(renderContext);
if (!DebugUtil.isDebugFeaturesEnabled() || !(renderContext instanceof WebXmlRenderContext)) {
return;
}
XmlStringBuilder xml = ((WebXmlRenderContext) renderContext).getWriter();
xml.appendTag("ui:debug");
writeDebugInfo(getUI(), xml);
xml.appendEndTag("ui:debug");
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class AbstractWFieldIndicatorRenderer method doRender.
/**
* Paints the given AbstractWFieldIndicator.
*
* @param component the WFieldErrorIndicator to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
AbstractWFieldIndicator fieldIndicator = (AbstractWFieldIndicator) component;
XmlStringBuilder xml = renderContext.getWriter();
WComponent validationTarget = fieldIndicator.getTargetComponent();
// Diagnosables takes care of thieir own messaging.
if (validationTarget == null || (validationTarget instanceof Diagnosable && !(validationTarget instanceof Input))) {
return;
}
if (validationTarget instanceof Input && !((Input) validationTarget).isReadOnly()) {
return;
}
List<Diagnostic> diags = fieldIndicator.getDiagnostics();
if (diags != null && !diags.isEmpty()) {
xml.appendTagOpen("ui:fieldindicator");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
switch(fieldIndicator.getFieldIndicatorType()) {
case INFO:
xml.appendAttribute("type", "info");
break;
case WARN:
xml.appendAttribute("type", "warn");
break;
case ERROR:
xml.appendAttribute("type", "error");
break;
default:
throw new SystemException("Cannot paint field indicator due to an invalid field indicator type: " + fieldIndicator.getFieldIndicatorType());
}
xml.appendAttribute("for", fieldIndicator.getRelatedFieldId());
xml.appendClose();
for (Diagnostic diag : diags) {
xml.appendTag("ui:message");
xml.appendEscaped(diag.getDescription());
xml.appendEndTag("ui:message");
}
xml.appendEndTag("ui:fieldindicator");
}
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class ColumnLayoutRenderer method doRender.
/**
* Paints the given WPanel's children.
*
* @param component the container to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WPanel panel = (WPanel) component;
XmlStringBuilder xml = renderContext.getWriter();
ColumnLayout layout = (ColumnLayout) panel.getLayout();
int childCount = panel.getChildCount();
Size hgap = layout.getHorizontalGap();
String hgapString = hgap == null ? null : hgap.toString();
Size vgap = layout.getVerticalGap();
String vgapString = vgap == null ? null : vgap.toString();
int cols = layout.getColumnCount();
xml.appendTagOpen("ui:columnlayout");
xml.appendOptionalAttribute("hgap", hgapString);
xml.appendOptionalAttribute("vgap", vgapString);
xml.appendClose();
// Column Definitions
for (int col = 0; col < cols; col++) {
xml.appendTagOpen("ui:column");
int width = layout.getColumnWidth(col);
xml.appendOptionalAttribute("width", width > 0, width);
switch(layout.getColumnAlignment(col)) {
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: " + layout.getColumnAlignment(col));
}
xml.appendEnd();
}
for (int i = 0; i < childCount; i++) {
xml.appendTag("ui:cell");
WComponent child = panel.getChildAt(i);
child.paint(renderContext);
xml.appendEndTag("ui:cell");
}
xml.appendEndTag("ui:columnlayout");
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WAbbrTextRenderer method doRender.
/**
* Paints the given WAbbrText.
*
* @param component the WAbbrText to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WAbbrText abbrText = (WAbbrText) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("abbr");
xml.appendOptionalAttribute("title", abbrText.getToolTip());
xml.appendOptionalAttribute("class", abbrText.getHtmlClass());
xml.appendClose();
xml.append(abbrText.getText(), abbrText.isEncodeText());
xml.appendEndTag("abbr");
}
Aggregations