@Override
	public void paint(final RenderContext renderContext) {
		if (key == null) {
			super.paint(renderContext);
			return;
		}

		Response response = getResponse();

		Object table = LOOKUP_TABLE.getTableForCacheKey(key);
		List<?> data = LOOKUP_TABLE.getTable(table);
		response.setContentType(WebUtilities.CONTENT_TYPE_XML);
		response.setHeader("Cache-Control", CacheType.DATALIST_CACHE.getSettings());

		XmlStringBuilder xml = new XmlStringBuilder(((WebXmlRenderContext) renderContext).getWriter());
		xml.write(XMLUtil.XML_DECLARATION);

		if (data != null) {
			xml.appendTagOpen("ui:datalist");
			xml.append(XMLUtil.UI_NAMESPACE);
			xml.appendAttribute("id", key);
			xml.appendClose();

			for (Object item : data) {
				// Check for null option (ie null or empty). Match isEmpty() logic.
				boolean isNull = item == null ? true : (item.toString().length() == 0);

				xml.appendTagOpen("ui:option");
				xml.appendAttribute("value", LOOKUP_TABLE.getCode(table, item));
				xml.appendOptionalAttribute("isNull", isNull, "true");
				xml.appendClose();
				xml.append(WebUtilities.encode(LOOKUP_TABLE.getDescription(table, item)));
				xml.appendEndTag("ui:option");
			}

			xml.appendEndTag("ui:datalist");
		}
	}
@ Override public void paint ( final RenderContext renderContext ) { if ( key == null ) { super . paint ( renderContext ) ; return ; } Response response = getResponse ( ) ; Object table = LOOKUP_TABLE . getTableForCacheKey ( key ) ; List < ? > data = LOOKUP_TABLE . getTable ( table ) ; response . setContentType ( WebUtilities . CONTENT_TYPE_XML ) ; response . setHeader ( "Cache-Control" , CacheType . DATALIST_CACHE . getSettings ( ) ) ; XmlStringBuilder xml = new XmlStringBuilder ( ( ( WebXmlRenderContext ) renderContext ) . getWriter ( ) ) ; xml . write ( XMLUtil . XML_DECLARATION ) ; if ( data != null ) { xml . appendTagOpen ( "ui:datalist" ) ; xml . append ( XMLUtil . UI_NAMESPACE ) ; xml . appendAttribute ( "id" , key ) ; xml . appendClose ( ) ; for ( Object item : data ) { boolean isNull = item == null ? true : ( item . toString ( ) . length ( ) == 0 ) ; xml . appendTagOpen ( "ui:option" ) ; xml . appendAttribute ( "value" , LOOKUP_TABLE . getCode ( table , item ) ) ; xml . appendOptionalAttribute ( "isNull" , isNull , "true" ) ; xml . appendClose ( ) ; xml . append ( WebUtilities . encode ( LOOKUP_TABLE . getDescription ( table , item ) ) ) ; xml . appendEndTag ( "ui:option" ) ; } xml . appendEndTag ( "ui:datalist" ) ; } }
{@inheritDoc}