use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WContentRenderer method doRender.
/**
* <p>
* Paints the given WContent.</p>
*
* <p>
* This paint method outputs a popup that opens browser window in which the content document will be displayed. The
* component is only rendered for requests in which the display() method of the content component has just been
* called.</p>
*
* <p>
* WContent's handleRequest() method will return the actual PDF document content via the use of an Escape.</p>
*
* @param component the WContent to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WContent content = (WContent) component;
XmlStringBuilder xml = renderContext.getWriter();
if (!content.isDisplayRequested()) {
// This is the normal situation.
return;
}
Object contentAccess = content.getContentAccess();
if (contentAccess == null) {
LOG.warn("No content specified");
return;
}
// Ok, the content is available and should be shown
switch(content.getDisplayMode()) {
case DISPLAY_INLINE:
case PROMPT_TO_SAVE:
xml.appendTagOpen("ui:redirect");
xml.appendUrlAttribute("url", content.getUrl());
xml.appendEnd();
break;
case OPEN_NEW_WINDOW:
xml.appendTagOpen("ui:popup");
xml.appendUrlAttribute("url", content.getUrl());
xml.appendAttribute("width", content.getWidth().replaceAll("px", ""));
xml.appendAttribute("height", content.getHeight().replaceAll("px", ""));
xml.appendOptionalAttribute("resizable", content.isResizable(), "true");
xml.appendEnd();
break;
default:
throw new IllegalStateException("Invalid display mode: " + content.getDisplayMode());
}
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WDataTableRenderer method doRender.
/**
* Paints the given WDataTable.
*
* @param component the WDataTable to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WDataTable table = (WDataTable) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:table");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", table.isHidden(), "true");
xml.appendOptionalAttribute("caption", table.getCaption());
switch(table.getType()) {
case TABLE:
xml.appendAttribute("type", "table");
break;
case HIERARCHIC:
xml.appendAttribute("type", "hierarchic");
break;
default:
throw new SystemException("Unknown table type: " + table.getType());
}
switch(table.getStripingType()) {
case ROWS:
xml.appendAttribute("striping", "rows");
break;
case COLUMNS:
xml.appendAttribute("striping", "cols");
break;
case NONE:
break;
default:
throw new SystemException("Unknown striping type: " + table.getStripingType());
}
switch(table.getSeparatorType()) {
case HORIZONTAL:
xml.appendAttribute("separators", "horizontal");
break;
case VERTICAL:
xml.appendAttribute("separators", "vertical");
break;
case BOTH:
xml.appendAttribute("separators", "both");
break;
case NONE:
break;
default:
throw new SystemException("Unknown separator type: " + table.getSeparatorType());
}
xml.appendClose();
if (table.getPaginationMode() != PaginationMode.NONE) {
paintPaginationElement(table, xml);
}
if (table.getSelectMode() != SelectMode.NONE) {
paintRowSelectionElement(table, xml);
}
if (table.getExpandMode() != ExpandMode.NONE) {
paintRowExpansionElement(table, xml);
}
if (table.isSortable()) {
paintSortElement(table, xml);
}
paintColumnHeadings(table, renderContext);
paintRows(table, renderContext);
paintTableActions(table, renderContext);
xml.appendEndTag("ui:table");
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WDataTableRenderer method paintRows.
/**
* Paints the rows of the table.
*
* @param table the table to paint the rows for.
* @param renderContext the RenderContext to paint to.
*/
private void paintRows(final WDataTable table, final WebXmlRenderContext renderContext) {
XmlStringBuilder xml = renderContext.getWriter();
TableDataModel model = table.getDataModel();
xml.appendTagOpen("ui:tbody");
xml.appendAttribute("id", table.getRepeater().getId());
xml.appendClose();
if (model.getRowCount() == 0) {
xml.appendTag("ui:nodata");
xml.appendEscaped(table.getNoDataMessage());
xml.appendEndTag("ui:nodata");
} else {
// If has at least one visible col, paint the rows.
final int columnCount = table.getColumnCount();
for (int i = 0; i < columnCount; i++) {
if (table.getColumn(i).isVisible()) {
doPaintRows(table, renderContext);
break;
}
}
}
xml.appendEndTag("ui:tbody");
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WDataTableRenderer method paintTableActions.
/**
* Paints the table actions of the table.
*
* @param table the table to paint the table actions for.
* @param renderContext the RenderContext to paint to.
*/
private void paintTableActions(final WDataTable table, final WebXmlRenderContext renderContext) {
XmlStringBuilder xml = renderContext.getWriter();
List<WButton> tableActions = table.getActions();
if (!tableActions.isEmpty()) {
boolean hasActions = false;
for (WButton button : tableActions) {
if (!button.isVisible()) {
continue;
}
if (!hasActions) {
hasActions = true;
xml.appendTag("ui:actions");
}
xml.appendTag("ui:action");
List<WDataTable.ActionConstraint> constraints = table.getActionConstraints(button);
if (constraints != null) {
for (WDataTable.ActionConstraint constraint : constraints) {
int minRows = constraint.getMinSelectedRowCount();
int maxRows = constraint.getMaxSelectedRowCount();
String message = constraint.getMessage();
String type = constraint.isError() ? "error" : "warning";
xml.appendTagOpen("ui:condition");
xml.appendOptionalAttribute("minSelectedRows", minRows > 0, minRows);
xml.appendOptionalAttribute("maxSelectedRows", maxRows > 0, maxRows);
xml.appendAttribute("type", type);
xml.appendAttribute("message", I18nUtilities.format(null, message));
xml.appendEnd();
}
}
button.paint(renderContext);
xml.appendEndTag("ui:action");
}
if (hasActions) {
xml.appendEndTag("ui:actions");
}
}
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WDecoratedLabelRenderer method doRender.
/**
* Paints the given WDecoratedLabel.
*
* @param component the WDecoratedLabel to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WDecoratedLabel label = (WDecoratedLabel) component;
XmlStringBuilder xml = renderContext.getWriter();
WComponent head = label.getHead();
WComponent body = label.getBody();
WComponent tail = label.getTail();
xml.appendTagOpen("ui:decoratedlabel");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", label.isHidden(), "true");
xml.appendClose();
if (head != null && head.isVisible()) {
xml.appendTagOpen("ui:labelhead");
xml.appendAttribute("id", label.getId() + "-head");
xml.appendClose();
head.paint(renderContext);
xml.appendEndTag("ui:labelhead");
}
xml.appendTagOpen("ui:labelbody");
xml.appendAttribute("id", label.getId() + "-body");
xml.appendClose();
body.paint(renderContext);
xml.appendEndTag("ui:labelbody");
if (tail != null && tail.isVisible()) {
xml.appendTagOpen("ui:labeltail");
xml.appendAttribute("id", label.getId() + "-tail");
xml.appendClose();
tail.paint(renderContext);
xml.appendEndTag("ui:labeltail");
}
xml.appendEndTag("ui:decoratedlabel");
}
Aggregations