}
public void encodeScript(FacesContext context, UIComponent component) throws IOException{
if(component instanceof UIPanelBar){
UIPanelBar panelBar = (UIPanelBar)component;
List items = getScriptPanelBarItems(context, panelBar);
ScriptOptions options = new ScriptOptions(component);
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
Object changeScript = panelBar.getAttributes().get("onitemchange");
if (changeScript != null && !changeScript.equals("")) {
JSFunctionDefinition function = new JSFunctionDefinition();
function.addParameter("event");
function.addToBody(changeScript);
options.addOption("onitemchange",function);
} else {
options.addOption("onitemchange","");
}
options.addOption("onclick", panelBar.getAttributes().get("onclick"));
options.addOption("mouseover", panelBar.getAttributes().get("onmouseover"));
options.addOption("mouseout", panelBar.getAttributes().get("onmouseout"));
options.addOption("mousemove", panelBar.getAttributes().get("onmousemove"));
options.addOption("items", items);
options.addOption("ajax", ajaxContext.isAjaxRequest());
StringBuffer script = new StringBuffer();
JSFunction function = new JSFunction("new Richfaces.PanelBar");
function.addParameter(panelBar.getClientId(context));
function.addParameter(options);
function.appendScript(script);
ResponseWriter writer = context.getResponseWriter();
writer.startElement(HTML.SCRIPT_ELEM, panelBar);