public void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
if (!(component instanceof AbstractImageSelectTool)) {
return;
}
String clientId = component.getClientId(context);
AbstractImageSelectTool imageSelectTool = (AbstractImageSelectTool) component;
String inputId = getInputId(context, imageSelectTool);
writer.startElement(HtmlConstants.DIV_ELEM, null);
writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, clientId, HtmlConstants.ID_ATTRIBUTE);
writer.startElement(HtmlConstants.INPUT_ELEM, component);
writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, inputId, HtmlConstants.ID_ATTRIBUTE);
writer.writeAttribute(HtmlConstants.TYPE_ATTR, "hidden", HtmlConstants.TYPE_ATTR);
writer.writeAttribute(HtmlConstants.NAME_ATTRIBUTE, inputId, HtmlConstants.NAME_ATTRIBUTE);
writer.writeAttribute(HtmlConstants.VALUE_ATTRIBUTE, getValueAsString(context, component), HtmlConstants.NAME_ATTRIBUTE);
// writer.endElement(HtmlConstants.INPUT_ELEM);
writer.startElement(HtmlConstants.SCRIPT_ELEM, null);
writer.writeAttribute(HtmlConstants.TYPE_ATTR, "text/javascript", "type");
final Map<String, Object> options = getOptions(context, imageSelectTool);
if (imageSelectTool.getWidgetVar() != null) {
writer.write("var " + imageSelectTool.getWidgetVar() + "=");
}
writer.writeText(new JSObject("RichFaces.ui.ImageSelectTool", clientId, options), null);
writer.writeText(";", null);
writer.endElement(HtmlConstants.SCRIPT_ELEM);
writer.endElement(HtmlConstants.DIV_ELEM);