* @see {@link org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd}
*/
protected void doEncodeEnd(final ResponseWriter writer,
final FacesContext context,
final UIComponent component) throws IOException {
UISuggestionBox suggestionBox = (UISuggestionBox) component;
if (!suggestionBox.isSubmitted()) {
suggestionBox.setRowIndex(-1);
writer.startElement(HTML.DIV_ELEM, component);
getUtils().encodeId(context, component);
StringBuffer clazz = new StringBuffer(
"dr-sb-common-container rich-sb-common-container ");
clazz.append(suggestionBox.getPopupClass() + " ").
append(suggestionBox.getStyleClass());
writer.writeAttribute("class", clazz, "popupClass");
int zIndex = suggestionBox.getZindex();
StringBuffer style = new StringBuffer("display:none; z-index: " + (zIndex + 1) + ";");
style.append(getSizeForStyle(component, "width", null, false));
style.append(getSizeForStyle(component, "height", null, false));
style.append(suggestionBox.getPopupStyle() + ";").
append(suggestionBox.getStyle() + ";");
writer.writeAttribute("style", style, "popupStyle");
UIComponent popupFacet = component.getFacet("popup");
if (null == popupFacet) {
popup.encode(this, context, component);
} else {
// Use facet as content of popup window
// suggestionBox.setPopup(popupFacet.getClientId(context));
renderChild(context, popupFacet);
}
writer.endElement(HTML.DIV_ELEM);
writer.startElement(HTML.DIV_ELEM, component);
writer.writeAttribute("id", component.getClientId(context) + "_script", null);
writer.writeAttribute("style", "display:none;", null);
writer.startElement(HTML.SCRIPT_ELEM, component);
writer.writeAttribute("type", "text/javascript", null);
writer.writeText(getScript(context, component), "script");
writer.endElement(HTML.SCRIPT_ELEM);
writer.endElement(HTML.DIV_ELEM);
writer.startElement("iframe", component);
writer.writeAttribute("src",
getResource("/org/richfaces/renderkit/html/images/spacer.gif")
.getUri(context, null), null);
writer.writeAttribute("id", component.getClientId(context)
+ "_iframe", null);
writer.writeAttribute(
"style", "position:absolute;display:none;z-index:" + zIndex + ";", null);
writer.endElement("iframe");
writer.startElement("input", component);
writer.writeAttribute("type", "hidden", null);
writer.writeAttribute("id", component.getClientId(context)
+ "_selection", null);
writer.writeAttribute("name", component.getClientId(context)
+ "_selection", null);
writer.endElement("input");
} else {
suggestionBox.setSubmitted(false);
}
// Fix for bug CH-1323.
((UISuggestionBox) component).setValue(null);
}