}
private String getScriptBtn(FacesContext facesContext, UIComponent uiComponent, String dateFormat, String popupButtonString)
throws IOException
{
HtmlBufferResponseWriterWrapper writer = HtmlBufferResponseWriterWrapper.
getInstance(facesContext.getResponseWriter());
HtmlInputCalendar calendar = (HtmlInputCalendar)uiComponent;
boolean renderButtonAsImage = calendar.isRenderPopupButtonAsImage();
writer.write("if (!document.layers) {\n");
writer.write("document.write('");
if (!renderButtonAsImage) {
// render the button
writer.startElement(HTML.INPUT_ELEM, uiComponent);
writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_BUTTON, null);
writeOnclickJsCalendarFunctionCall(writer,facesContext,uiComponent,dateFormat);
if(popupButtonString==null)
popupButtonString="...";
writer.writeAttribute(HTML.VALUE_ATTR, StringEscapeUtils.escapeJavaScript(popupButtonString), null);
/*
if (renderButtonAsImage) {
writer.writeAttribute(HTML.ID_ATTR, buttonId, null);
writer.writeAttribute(HTML.NAME_ATTR, buttonId, null);
writer.writeAttribute(HTML.STYLE_ATTR, "visibility:hidden;",null);
} else {
HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.UNIVERSAL_ATTRIBUTES);
}
*/
writer.endElement(HTML.INPUT_ELEM);
} else {
// render the image
writer.startElement(HTML.IMG_ELEM, uiComponent);
writer.writeAttribute(HTML.SRC_ATTR, AddResource.getResourceMappedPath(HtmlCalendarRenderer.class, "images/calendar.gif", facesContext), null);
writer.writeAttribute(HTML.STYLE_ATTR, "vertical-align:bottom;", null);
//writer.writeAttribute(HTML.ONCLICK_ATTR, "document.getElementById(\\'"+buttonId+"\\').click()",null);
writeOnclickJsCalendarFunctionCall(writer, facesContext,uiComponent,dateFormat);
//writer.writeAttribute(HTML.ONMOUSEOVER_ATTR, "this.style.cursor=\\'hand\\';", null);
//writer.writeAttribute(HTML.ONMOUSEOUT_ATTR, "this.style.cursor=\\'default\\';", null);
writer.endElement(HTML.IMG_ELEM);
}
writer.write("');");
writer.write("\n}");
return writer.toString();
}