protected void encodeButton(FacesContext context, UIComponent component) throws IOException { FacesContext currentInstance = FacesContext.getCurrentInstance(); ScrollButton scrollButton = (ScrollButton) component; ResponseWriter writer = context.getResponseWriter(); writeIdAttribute(context, scrollButton); writer.startElement("div", scrollButton); writer.writeAttribute( "class", Styles.getCSSClass( context, scrollButton, scrollButton.getButtonStyle(), StyleGroup.regularStyleGroup(), scrollButton.getButtonClass(), getDefaultScrollButtonClass()), null); writer.writeAttribute("nowrap", "nowrap", null); writer.writeAttribute("align", "center", null); writer.writeAttribute("valign", "middle", null); String imageUrl; String buttonImageUrl = (String) scrollButton.getAttributes().get("buttonImageUrl"); if (scrollButton.getScrollDirection().equals(ScrollDirection.UP)) imageUrl = Resources.getURL(context, buttonImageUrl, null, "input/scrollButtonUp.gif"); else imageUrl = Resources.getURL(context, buttonImageUrl, null, "input/scrollButtonDown.gif"); writer.startElement("img", scrollButton); writeIdAttribute(context, scrollButton); writer.writeAttribute("src", imageUrl, null); writer.endElement("img"); writer.endElement("div"); InitScript initScript = renderInitScript(currentInstance, scrollButton); Rendering.renderInitScripts(currentInstance, initScript); }
private JSONObject getStylingParamsObj(FacesContext context, ScrollButton scrollButton) { JSONObject stylingParams = new JSONObject(); Styles.addStyleJsonParam( context, scrollButton, stylingParams, "buttonClass", scrollButton.getButtonStyle(), scrollButton.getButtonClass()); Styles.addStyleJsonParam( context, scrollButton, stylingParams, "rollover", scrollButton.getRolloverButtonStyle(), scrollButton.getRolloverButtonClass()); return stylingParams; }
protected InitScript renderInitScript(FacesContext context, ScrollButton scrollButton) throws IOException { ScriptBuilder buf = new ScriptBuilder(); JSONObject stylingParams = getStylingParamsObj(context, scrollButton); buf.initScript( context, scrollButton, "O$.ScrollButton._init", scrollButton.getParent().getClientId(context), scrollButton.getScrollDirection().toString(), stylingParams); return new InitScript( buf.toString(), new String[] { TableUtil.getTableUtilJsURL(context), Resources.internalURL(context, "timetable/scrollButton.js") }); }