Paints the given WAbbrText.

@param component the WAbbrText to paint.
@param renderContext the RenderContext to paint to.
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");
	}
1304007
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WSection section = (WSection) component;
		XmlStringBuilder xml = renderContext.getWriter();

		boolean renderChildren = isRenderContent(section);

		xml.appendTagOpen("ui:section");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		if (SectionMode.LAZY.equals(section.getMode())) {
			xml.appendOptionalAttribute("hidden", !renderChildren, "true");
		} else {
			xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
		}

		SectionMode mode = section.getMode();
		if (mode != null) {
			switch (mode) {
				case LAZY:
					xml.appendAttribute("mode", "lazy");
					break;
				case EAGER:
					xml.appendAttribute("mode", "eager");
					break;
				default:
					throw new SystemException("Unknown section mode: " + section.getMode());
			}
		}

		xml.appendClose();

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

		if (renderChildren) {
			// Label
			section.getDecoratedLabel().paint(renderContext);
			// Content
			section.getContent().paint(renderContext);
		}

		xml.appendEndTag("ui:section");
	}
527115
@Override
	protected void paintComponent(final RenderContext renderContext) {
		if (renderContext instanceof WebXmlRenderContext) {
			PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter();
			writer.println(getMessage());

			if (developerFriendly) {
				writer.println("<pre style=\"background: lightgrey\">");
				writer.println("Additional details for the developer:");
				writer.println();
				error.printStackTrace(writer);
				writer.println("</pre>");
			}
		}
	}
738844
@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();
	}
916254
@Override
	public void paint(final RenderContext renderContext) {
		// Check interceptor is enabled
		if (!DebugValidateXML.isEnabled()) {
			super.paint(renderContext);
			return;
		}

		if (!(renderContext instanceof WebXmlRenderContext)) {
			LOG.warn("Unable to validate against a " + renderContext);
			super.paint(renderContext);
			return;
		}

		LOG.debug("Validate XML Interceptor: Start");

		WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext;
		PrintWriter writer = webRenderContext.getWriter();

		// Generate XML
		StringWriter tempBuffer = new StringWriter();
		PrintWriter tempWriter = new PrintWriter(tempBuffer);
		WebXmlRenderContext tempContext = new WebXmlRenderContext(tempWriter, UIContextHolder.
				getCurrent().getLocale());

		super.paint(tempContext);
		String xml = tempBuffer.toString();

		// If no errors, check against the schema
		String error = DebugValidateXML.validateXMLAgainstSchema(xml);

		if (error != null) {
			// XML is NOT valid, so Report Errors and Wrap the original XML
			LOG.debug("Validate XML Interceptor: XML Has Errors");
			writer.println("<div>");

			writer.println("<div>");
			writer.println("Invalid XML");
			writer.println("<ul><li>" + WebUtilities.encode(error) + "</li></ul>");
			writer.println("<br/>");
			writer.println("</div>");

			// If a schema error detected, Wrap XML so line numbers reported in validation message are correct
			String testXML = DebugValidateXML.wrapXMLInRootElement(xml);
			paintOriginalXML(testXML, writer);

			writer.println("</div>");
		} else {
			// XML is valid
			writer.write(xml);
		}

		LOG.debug("Validate XML Interceptor: Finished");
	}
1342430
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WFieldLayout fieldLayout = (WFieldLayout) component;
		XmlStringBuilder xml = renderContext.getWriter();
		int labelWidth = fieldLayout.getLabelWidth();
		String title = fieldLayout.getTitle();

		xml.appendTagOpen("ui:fieldlayout");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendOptionalAttribute("hidden", fieldLayout.isHidden(), "true");
		xml.appendOptionalAttribute("labelWidth", labelWidth > 0, labelWidth);
		xml.appendAttribute("layout", fieldLayout.getLayoutType());
		xml.appendOptionalAttribute("title", title);
		// Ordered layout
		if (fieldLayout.isOrdered()) {
			xml.appendAttribute("ordered", fieldLayout.getOrderedOffset());
		}
		xml.appendClose();

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

		// Paint Fields
		paintChildren(fieldLayout, renderContext);

		xml.appendEndTag("ui:fieldlayout");
	}
177007
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WValidationErrors errors = (WValidationErrors) component;
		XmlStringBuilder xml = renderContext.getWriter();

		if (errors.hasErrors()) {
			xml.appendTagOpen("ui:validationerrors");
			xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
			xml.appendOptionalAttribute("track", component.isTracking(), "true");
			xml.appendOptionalAttribute("title", errors.getTitleText());
			xml.appendClose();

			for (GroupedDiagnositcs nextGroup : errors.getGroupedErrors()) {
				// Render each diagnostic message in this group.
				for (Diagnostic nextMessage : nextGroup.getDiagnostics()) {
					xml.appendTagOpen("ui:error");
					WComponent forComponent = nextMessage.getComponent();

					if (forComponent != null) {
						UIContextHolder.pushContext(nextMessage.getContext());

						try {
							xml.appendAttribute("for", forComponent.getId());
						} finally {
							UIContextHolder.popContext();
						}
					}

					xml.appendClose();

					// DiagnosticImpl has been extended to support rendering
					// of a WComponent as the message.
					if (nextMessage instanceof DiagnosticImpl) {
						WComponent messageComponent = ((DiagnosticImpl) nextMessage)
								.createDiagnosticErrorComponent();

						// We add the component to a throw-away container so that it renders with the correct ID.
						WContainer container = new WContainer() {
							@Override
							public String getId() {
								return component.getId();
							}
						};

						container.add(messageComponent);
						messageComponent.paint(renderContext);
						container.remove(messageComponent);
						container.reset();
					} else {
						xml.append(nextMessage.getDescription());
					}

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

			xml.appendEndTag("ui:validationerrors");
		}
	}
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);
		}
	}
1346970
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WTabSet tabSet = (WTabSet) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:tabset");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendAttribute("type", getTypeAsString(tabSet.getType()));
		xml.appendOptionalAttribute("disabled", tabSet.isDisabled(), "true");
		xml.appendOptionalAttribute("hidden", tabSet.isHidden(), "true");
		xml.appendOptionalAttribute("contentHeight", tabSet.getContentHeight());
		xml.appendOptionalAttribute("showHeadOnly", tabSet.isShowHeadOnly(), "true");
		xml.appendOptionalAttribute("single",
				TabSetType.ACCORDION.equals(tabSet.getType()) && tabSet.isSingle(),
				"true");
		if (WTabSet.TabSetType.ACCORDION.equals(tabSet.getType())) {
			xml.appendOptionalAttribute("groupName", tabSet.getGroupName());
		}
		xml.appendClose();

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

		paintChildren(tabSet, renderContext);

		xml.appendEndTag("ui:tabset");
	}
894867
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WVideo videoComponent = (WVideo) component;
		XmlStringBuilder xml = renderContext.getWriter();
		Video[] video = videoComponent.getVideo();

		if (video == null || video.length == 0) {
			return;
		}

		Track[] tracks = videoComponent.getTracks();
		WVideo.Controls controls = videoComponent.getControls();
		int width = videoComponent.getWidth();
		int height = videoComponent.getHeight();
		int duration = video[0].getDuration();

		// Check for alternative text
		String alternativeText = videoComponent.getAltText();

		if (alternativeText == null) {
			LOG.warn("Video should have a description.");
			alternativeText = null;
		} else {
			alternativeText = I18nUtilities.format(null, alternativeText);
		}

		xml.appendTagOpen("ui:video");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendOptionalUrlAttribute("poster", videoComponent.getPosterUrl());
		xml.appendOptionalAttribute("alt", alternativeText);
		xml.appendOptionalAttribute("autoplay", videoComponent.isAutoplay(), "true");
		xml.appendOptionalAttribute("mediagroup", videoComponent.getMediaGroup());
		xml.appendOptionalAttribute("loop", videoComponent.isLoop(), "true");
		xml.appendOptionalAttribute("muted", videoComponent.isMuted(), "true");
		xml.appendOptionalAttribute("hidden", videoComponent.isHidden(), "true");
		xml.appendOptionalAttribute("disabled", videoComponent.isDisabled(), "true");
		xml.appendOptionalAttribute("toolTip", videoComponent.getToolTip());
		xml.appendOptionalAttribute("width", width > 0, width);
		xml.appendOptionalAttribute("height", height > 0, height);
		xml.appendOptionalAttribute("duration", duration > 0, duration);

		switch (videoComponent.getPreload()) {
			case NONE:
				xml.appendAttribute("preload", "none");
				break;

			case META_DATA:
				xml.appendAttribute("preload", "metadata");
				break;

			case AUTO:
			default:
				break;
		}

		if (controls != null && !WVideo.Controls.NATIVE.equals(controls)) {
			switch (controls) {
				case NONE:
					xml.appendAttribute("controls", "none");
					break;

				case ALL:
					xml.appendAttribute("controls", "all");
					break;

				case PLAY_PAUSE:
					xml.appendAttribute("controls", "play");
					break;

				case DEFAULT:
					xml.appendAttribute("controls", "default");
					break;

				default:
					LOG.error("Unknown control type: " + controls);
			}
		}

		xml.appendClose();

		String[] urls = videoComponent.getVideoUrls();

		for (int i = 0; i < urls.length; i++) {
			xml.appendTagOpen("ui:src");
			xml.appendUrlAttribute("uri", urls[i]);
			xml.appendOptionalAttribute("type", video[i].getMimeType());

			if (video[i].getSize() != null) {
				xml.appendOptionalAttribute("width", video[i].getSize().width > 0, video[i].
						getSize().width);
				xml.appendOptionalAttribute("height", video[i].getSize().height > 0, video[i].
						getSize().height);
			}

			xml.appendEnd();
		}

		if (tracks != null && tracks.length > 0) {
			String[] trackUrls = videoComponent.getTrackUrls();

			for (int i = 0; i < tracks.length; i++) {
				xml.appendTagOpen("ui:track");
				xml.appendUrlAttribute("src", trackUrls[i]);
				xml.appendOptionalAttribute("lang", tracks[i].getLanguage());
				xml.appendOptionalAttribute("desc", tracks[i].getDescription());
				xml.appendOptionalAttribute("kind", trackKindToString(tracks[i].getKind()));
				xml.appendEnd();
			}
		}

		xml.appendEndTag("ui:video");
	}
901909
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WTab tab = (WTab) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:tab");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendOptionalAttribute("open", tab.isOpen(), "true");
		xml.appendOptionalAttribute("disabled", tab.isDisabled(), "true");
		xml.appendOptionalAttribute("hidden", tab.isHidden(), "true");
		xml.appendOptionalAttribute("toolTip", tab.getToolTip());

		switch (tab.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 tab mode: " + tab.getMode());
		}

		if (tab.getAccessKey() != 0) {
			xml.appendAttribute("accessKey", String.valueOf(Character.
					toUpperCase(tab.getAccessKey())));
		}

		xml.appendClose();

		// Paint label
		tab.getTabLabel().paint(renderContext);

		// Paint content
		WComponent content = tab.getContent();

		xml.appendTagOpen("ui:tabcontent");
		xml.appendAttribute("id", tab.getId() + "-content");
		xml.appendClose();

		// Render content if not EAGER Mode or is EAGER and is the current AJAX trigger
		if (content != null && (TabMode.EAGER != tab.getMode() || AjaxHelper.isCurrentAjaxTrigger(
				tab))) {
			// Visibility of content set in prepare paint
			content.paint(renderContext);
		}

		xml.appendEndTag("ui:tabcontent");

		xml.appendEndTag("ui:tab");
	}
417864
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		AbstractWFieldIndicator fieldIndicator = (AbstractWFieldIndicator) component;
		XmlStringBuilder xml = renderContext.getWriter();

		WComponent validationTarget = fieldIndicator.getTargetComponent();

		// no need to render an indicator for nothing.
		// 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");
		}
	}
1372796
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WCheckBoxSelect select = (WCheckBoxSelect) component;
		XmlStringBuilder xml = renderContext.getWriter();
		int cols = select.getButtonColumns();
		boolean readOnly = select.isReadOnly();

		xml.appendTagOpen("ui:checkboxselect");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendOptionalAttribute("hidden", select.isHidden(), "true");
		if (readOnly) {
			xml.appendAttribute("readOnly", "true");
		} else {
			int min = select.getMinSelect();
			int max = select.getMaxSelect();
			xml.appendOptionalAttribute("disabled", select.isDisabled(), "true");
			xml.appendOptionalAttribute("required", select.isMandatory(), "true");
			xml.appendOptionalAttribute("submitOnChange", select.isSubmitOnChange(), "true");
			xml.appendOptionalAttribute("toolTip", component.getToolTip());
			xml.appendOptionalAttribute("accessibleText", component.getAccessibleText());
			xml.appendOptionalAttribute("min", min > 0, min);
			xml.appendOptionalAttribute("max", max > 0, max);
		}
		xml.appendOptionalAttribute("frameless", select.isFrameless(), "true");

		switch (select.getButtonLayout()) {
			case COLUMNS:
				xml.appendAttribute("layout", "column");
				xml.appendOptionalAttribute("layoutColumnCount", cols > 0, cols);
				break;
			case FLAT:
				xml.appendAttribute("layout", "flat");
				break;
			case STACKED:
				xml.appendAttribute("layout", "stacked");
				break;
			default:
				throw new SystemException("Unknown layout type: " + select.getButtonLayout());
		}


		xml.appendClose();

		// Options
		List<?> options = select.getOptions();
		boolean renderSelectionsOnly = readOnly;

		if (options != null) {
			int optionIndex = 0;
			List<?> selections = select.getSelected();

			for (Object option : options) {
				if (option instanceof OptionGroup) {
					throw new SystemException("Option groups not supported in WCheckBoxSelect.");
				} else {
					renderOption(select, option, optionIndex++, xml, selections,
							renderSelectionsOnly);
				}
			}
		}
		if (!readOnly) {
			DiagnosticRenderUtil.renderDiagnostics(select, renderContext);
		}
		xml.appendEndTag("ui:checkboxselect");
	}
367942
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WPartialDateField dateField = (WPartialDateField) component;
		XmlStringBuilder xml = renderContext.getWriter();
		boolean readOnly = dateField.isReadOnly();

		String date = formatDate(dateField);

		xml.appendTagOpen("ui:datefield");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendOptionalAttribute("hidden", dateField.isHidden(), "true");
		xml.appendOptionalAttribute("date", date);
		if (readOnly) {
			xml.appendAttribute("readOnly", "true");
		} else {
			xml.appendAttribute("allowPartial", "true");
			xml.appendOptionalAttribute("disabled", dateField.isDisabled(), "true");
			xml.appendOptionalAttribute("required", dateField.isMandatory(), "true");
			xml.appendOptionalAttribute("toolTip", dateField.getToolTip());
			xml.appendOptionalAttribute("accessibleText", dateField.getAccessibleText());
			WComponent submitControl = dateField.getDefaultSubmitButton();
			String submitControlId = submitControl == null ? null : submitControl.getId();
			xml.appendOptionalAttribute("buttonId", submitControlId);
		}

		xml.appendClose();

		if (date == null) {
			xml.appendEscaped(dateField.getText());
		}

		if (!readOnly) {
			DiagnosticRenderUtil.renderDiagnostics(dateField, renderContext);
		}
		xml.appendEndTag("ui:datefield");
	}
1258247
@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");
	}
129643
@Override
	public void paint(final RenderContext renderContext) {
		WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext;
		PrintWriter writer = webRenderContext.getWriter();

		beforePaint(writer);
		getBackingComponent().paint(renderContext);
		afterPaint(writer);
	}
146442
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WPopup popup = (WPopup) component;
		XmlStringBuilder xml = renderContext.getWriter();
		int width = popup.getWidth();
		int height = popup.getHeight();
		String targetWindow = popup.getTargetWindow();

		xml.appendTagOpen("ui:popup");
		xml.appendUrlAttribute("url", popup.getUrl());
		xml.appendOptionalAttribute("width", width > 0, width);
		xml.appendOptionalAttribute("height", height > 0, height);
		xml.appendOptionalAttribute("resizable", popup.isResizable(), "true");
		xml.appendOptionalAttribute("showScrollbars", popup.isScrollable(), "true");
		xml.appendOptionalAttribute("targetWindow", !Util.empty(targetWindow), targetWindow);
		xml.appendClose();
		xml.appendEndTag("ui:popup");
	}