Paints the given WDecoratedLabel.

@param component the WDecoratedLabel to paint.
@param renderContext the RenderContext to paint to.
195149
@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");
	}
101725
@Override
	protected void paintComponent(final RenderContext renderContext) {
		if (getState() == DISPLAY_STATE) {
			setState(ACTIVE_STATE);
			showWindow(renderContext);
		} else if (getState() == ACTIVE_STATE && isTargeted()) {
			getComponentModel().wrappedContent.paint(renderContext);
		}
	}
1235936
@Override
	public void paint(final RenderContext renderContext) {
		getBackingComponent().paint(renderContext);

		// We don't want to remember the focus for the next render because on
		// a multi portlet page, we'd end up with multiple portlets trying to
		// set the focus.
		UIContext uic = UIContextHolder.getCurrent();

		if (uic.isFocusRequired()) {
			boolean sticky = ConfigurationProperties.getStickyFocus();

			if (!sticky) {
				uic.setFocussed(null, null);
				uic.setFocusRequired(false);
			}
		}
	}
276149
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WMenuItem item = (WMenuItem) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:menuitem");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");

		if (item.isSubmit()) {
			xml.appendAttribute("submit", "true");
		} else {
			xml.appendOptionalUrlAttribute("url", item.getUrl());
			xml.appendOptionalAttribute("targetWindow", item.getTargetWindow());
		}

		xml.appendOptionalAttribute("disabled", item.isDisabled(), "true");
		xml.appendOptionalAttribute("hidden", item.isHidden(), "true");
		xml.appendOptionalAttribute("selected", item.isSelected(), "true");
		xml.appendOptionalAttribute("role", getRole(item));
		xml.appendOptionalAttribute("cancel", item.isCancel(), "true");
		xml.appendOptionalAttribute("msg", item.getMessage());
		xml.appendOptionalAttribute("toolTip", item.getToolTip());

		if (item.isTopLevelItem()) {
			xml.appendOptionalAttribute("accessKey", item.getAccessKeyAsString());
		}

		xml.appendClose();

		item.getDecoratedLabel().paint(renderContext);

		xml.appendEndTag("ui:menuitem");
	}
1001255
@Override
	public void paint(final RenderContext renderContext) {
		if (windowId == null) {
			super.paint(renderContext);
		} else {
			// Get the window component
			ComponentWithContext target = WebUtilities.getComponentById(windowId, true);
			if (target == null) {
				throw new SystemException("No window component for id " + windowId);
			}

			UIContext uic = UIContextHolder.getCurrentPrimaryUIContext();
			Environment originalEnvironment = uic.getEnvironment();
			uic.setEnvironment(new EnvironmentDelegate(originalEnvironment, windowId, target));

			UIContextHolder.pushContext(target.getContext());
			try {
				super.paint(renderContext);
			} finally {
				uic.setEnvironment(originalEnvironment);
				UIContextHolder.popContext();
			}
		}
	}
150721
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WFieldSet fieldSet = (WFieldSet) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:fieldset");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendOptionalAttribute("hidden", fieldSet.isHidden(), "true");

		switch (fieldSet.getFrameType()) {
			case NO_BORDER:
				xml.appendOptionalAttribute("frame", "noborder");
				break;

			case NO_TEXT:
				xml.appendOptionalAttribute("frame", "notext");
				break;

			case NONE:
				xml.appendOptionalAttribute("frame", "none");
				break;

			case NORMAL:
			default:
				break;
		}

		xml.appendOptionalAttribute("required", fieldSet.isMandatory(), "true");
		xml.appendClose();

		// Render margin
		MarginRendererUtil.renderMargin(fieldSet, renderContext);

		// Label
		WDecoratedLabel label = fieldSet.getTitle();
		label.paint(renderContext);

		// Children
		xml.appendTag("ui:content");
		int size = fieldSet.getChildCount();

		for (int i = 0; i < size; i++) {
			WComponent child = fieldSet.getChildAt(i);

			// Skip label, as it has already been painted
			if (child != label) {
				child.paint(renderContext);
			}
		}

		xml.appendEndTag("ui:content");
		DiagnosticRenderUtil.renderDiagnostics(fieldSet, renderContext);
		xml.appendEndTag("ui:fieldset");
	}
780038
@Override
	protected void afterPaint(final RenderContext renderContext) {
		super.afterPaint(renderContext);

		final int size = getChildCount();

		for (int i = 0; i < size; i++) {
			WComponent child = getChildAt(i);
			child.reset();
		}
	}
43622
@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");
	}
230358
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		XmlStringBuilder xml = renderContext.getWriter();
		xml.appendTagOpen("hr");
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendEnd();
	}
556030
@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");
	}
971307
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WTableRowRenderer renderer = (WTableRowRenderer) component;
		XmlStringBuilder xml = renderContext.getWriter();
		WTable table = renderer.getTable();
		TableModel dataModel = table.getTableModel();

		int[] columnOrder = table.getColumnOrder();
		final int numCols = columnOrder == null ? table.getColumnCount() : columnOrder.length;

		// Get current row details
		RowIdWrapper wrapper = renderer.getCurrentRowIdWrapper();
		List<Integer> rowIndex = wrapper.getRowIndex();

		boolean tableSelectable = table.getSelectMode() != SelectMode.NONE;
		boolean rowSelectable = tableSelectable && dataModel.isSelectable(rowIndex);
		boolean rowSelected = rowSelectable && table.getSelectedRows().contains(wrapper.getRowKey());

		boolean tableExpandable = table.getExpandMode() != WTable.ExpandMode.NONE;
		boolean rowExpandable = tableExpandable && dataModel.isExpandable(rowIndex) && wrapper.
				hasChildren();
		boolean rowExpanded = rowExpandable && table.getExpandedRows().contains(wrapper.getRowKey());

		String rowIndexAsString = TableUtil.rowIndexListToString(rowIndex);

		xml.appendTagOpen("ui:tr");
		xml.appendAttribute("rowIndex", rowIndexAsString);
		xml.appendOptionalAttribute("unselectable", !rowSelectable, "true");
		xml.appendOptionalAttribute("selected", rowSelected, "true");
		xml.appendOptionalAttribute("expandable", rowExpandable && !rowExpanded, "true");
		xml.appendClose();

		// wrote the column cell.
		boolean isRowHeader = table.isRowHeaders(); // need this before we get into the loop
		for (int i = 0; i < numCols; i++) {
			int colIndex = columnOrder == null ? i : columnOrder[i];
			WTableColumn col = table.getColumn(colIndex);
			String cellTag = "ui:td";

			if (col.isVisible()) {
				if (isRowHeader) { // The first rendered column will be the row header.
					cellTag = "ui:th";
					isRowHeader = false; // only set one col as the row header.
				}
				xml.appendTag(cellTag);
				renderer.getRenderer(colIndex).paint(renderContext);
				xml.appendEndTag(cellTag);
			}
		}

		if (rowExpandable) {
			xml.appendTagOpen("ui:subtr");
			xml.appendOptionalAttribute("open", rowExpanded, "true");
			xml.appendClose();

			if (rowExpanded || table.getExpandMode() == ExpandMode.CLIENT) {
				renderChildren(renderer, renderContext, wrapper.getChildren());
			}

			xml.appendEndTag("ui:subtr");
		}

		xml.appendEndTag("ui:tr");
	}
921788
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WDataTableRowRenderer renderer = (WDataTableRowRenderer) component;
		XmlStringBuilder xml = renderContext.getWriter();
		WDataTable table = renderer.getTable();
		TableDataModel dataModel = table.getDataModel();
		UIContext uic = UIContextHolder.getCurrent();

		final int numCols = table.getColumnCount();
		int[] columnOrder = table.getColumnOrder();
		int rowIndex = getRowIndex(table, (SubUIContext) uic);
		boolean unselectable = table.getSelectMode() != SelectMode.NONE
				&& !dataModel.isSelectable(rowIndex);

		xml.appendTagOpen("ui:tr");
		xml.appendAttribute("rowIndex", rowIndex);
		xml.appendOptionalAttribute("unselectable", unselectable, "true");
		xml.appendOptionalAttribute("selected", table.getSelectedRows().contains(rowIndex), "true");
		xml.appendOptionalAttribute("filterValues", getFilterValues(dataModel, rowIndex));

		if (table.getExpandMode() != WDataTable.ExpandMode.NONE && dataModel instanceof TreeTableDataModel) {
			TableTreeNode node = ((TreeTableDataModel) dataModel).getNodeAtLine(rowIndex);
			boolean expandable = !node.isLeaf() && !node.isExpanded();
			xml.appendOptionalAttribute("expandable", expandable, "true");
		}

		xml.appendClose();

		if (table.isShowRowHeaders()) {
			xml.appendTag("ui:th");
			renderer.getRowHeader().paint(renderContext);
			xml.appendEndTag("ui:th");
		}

		for (int i = 0; i < numCols; i++) {
			int colIndex = columnOrder == null ? i : columnOrder[i];
			WTableColumn col = table.getColumn(colIndex);

			if (col.isVisible()) {
				xml.appendTag("ui:td");
				renderer.getRenderer(colIndex).paint(renderContext);
				xml.appendEndTag("ui:td");
			}
		}

		if (table.getExpandMode() != WDataTable.ExpandMode.NONE && dataModel instanceof TreeTableDataModel) {
			TreeTableDataModel treeModel = (TreeTableDataModel) dataModel;
			TableTreeNode node = treeModel.getNodeAtLine(rowIndex);

			if (!node.isLeaf()) {
				xml.appendTagOpen("ui:subtr");
				xml.appendOptionalAttribute("open", node.isExpanded(), "true");
				xml.appendClose();

				if (node.isExpanded() || table.getExpandMode() == ExpandMode.CLIENT) {
					WRepeater repeater = table.getRepeater();

					// If there a renderer specified by any child, we only paint content that has a specified renderer
					boolean rendererPresent = false;

					for (Iterator<TreeNode> i = node.children(); !rendererPresent && i.hasNext();) {
						TableTreeNode child = (TableTreeNode) i.next();

						if (child.getRendererClass() != null) {
							rendererPresent = true;
						}
					}

					// Paint immediate children only.
					if (rendererPresent) {
						xml.appendTagOpen("ui:content");
						xml.appendOptionalAttribute("spanAllCols", node.isRendererSpansAllCols(),
								"true");
						xml.appendClose();

						for (Iterator<TreeNode> i = node.children(); i.hasNext();) {
							TableTreeNode child = (TableTreeNode) i.next();
							Integer rowId = child.getRowIndex() - 1;
							UIContext nodeContext = repeater.getRowContext(rowId);

							WComponent expandedRenderer = renderer.getExpandedTreeNodeRenderer(
									child.getRendererClass());

							if (expandedRenderer != null) {
								UIContextHolder.pushContext(nodeContext);

								try {
									expandedRenderer.paint(renderContext);
								} finally {
									UIContextHolder.popContext();
								}
							}
						}

						xml.appendEndTag("ui:content");
					} else {
						for (Iterator<TreeNode> i = node.children(); i.hasNext();) {
							TableTreeNode child = (TableTreeNode) i.next();
							Integer rowId = child.getRowIndex() - 1;
							UIContext nodeContext = repeater.getRowContext(rowId);

							UIContextHolder.pushContext(nodeContext);

							try {
								render(component, renderContext);
							} finally {
								UIContextHolder.popContext();
							}
						}
					}
				}

				xml.appendEndTag("ui:subtr");
			}
		}

		xml.appendEndTag("ui:tr");
	}
80989
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WTabGroup group = (WTabGroup) component;
		paintChildren(group, renderContext);
	}
1279775
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WTemplate template = (WTemplate) component;

		// Setup the context
		Map<String, Object> context = new HashMap<>();
		// Make the component available under the "wc" key.
		context.put("wc", template);
		// Load the parameters
		context.putAll(template.getParameters());

		// Get template renderer for the engine
		String engine = template.getEngineName();
		if (Util.empty(engine)) {
			engine = ConfigurationProperties.getDefaultRenderingEngine();
		}
		TemplateRenderer templateRenderer = TemplateRendererFactory.newInstance(engine);

		// Render
		if (!Util.empty(template.getTemplateName())) {
			// Render the template
			templateRenderer.renderTemplate(template.getTemplateName(), context, template.getTaggedComponents(), renderContext.getWriter(),
					template.getEngineOptions());
		} else if (!Util.empty(template.getInlineTemplate())) {
			// Render inline
			templateRenderer.renderInline(template.getInlineTemplate(), context, template.getTaggedComponents(), renderContext.getWriter(),
					template.getEngineOptions());
		}
	}
693978
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WMenuItemGroup group = (WMenuItemGroup) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:menugroup");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendClose();

		paintChildren(group, renderContext);

		xml.appendEndTag("ui:menugroup");
	}
738963
@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_MULTIDROPDOWN_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");
	}
1245304
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WToggleButton toggle = (WToggleButton) component;
		XmlStringBuilder xml = renderContext.getWriter();
		boolean readOnly = toggle.isReadOnly();


		xml.appendTagOpen("ui:togglebutton");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendOptionalAttribute("hidden", toggle.isHidden(), "true");
		xml.appendOptionalAttribute("selected", toggle.isSelected(), "true");
		if (readOnly) {
			xml.appendAttribute("readOnly", "true");
		} else {
			WComponentGroup<WCheckBox> group = toggle.getGroup();
			String groupName = group == null ? null : group.getId();
			xml.appendOptionalAttribute("groupName", groupName);
			xml.appendOptionalAttribute("disabled", toggle.isDisabled(), "true");
			xml.appendOptionalAttribute("submitOnChange", toggle.isSubmitOnChange(), "true");
			xml.appendOptionalAttribute("toolTip", toggle.getToolTip());
			xml.appendOptionalAttribute("accessibleText", toggle.getAccessibleText());
		}
		xml.appendClose();
		String text = toggle.getText();
		if (text != null) {
			xml.appendEscaped(text);
		}
		if (!readOnly) {
			DiagnosticRenderUtil.renderDiagnostics(toggle, renderContext);
		}
		xml.appendEndTag("ui:togglebutton");
	}