component.queueEvent(actionEvent);
}
}
public String getOnClick(FacesContext context, UIComponent component) {
UIToggleControl tgComp = (UIToggleControl)component;
UITogglePanel panel = tgComp.getPanel();
//UITogglePanel panel = tgComp.getPanel(context);
//denis
String switchType = panel.getSwitchType();
StringBuffer onClick = new StringBuffer();
String userOnClick = (String)component.getAttributes().get("onclick");
if(userOnClick!=null) {
onClick.append(userOnClick);
if(!userOnClick.trim().endsWith(";")) {
onClick.append("; ");
}
}
if(UITogglePanel.CLIENT_METHOD.equals(switchType)) {
// Client
String panelId = panel.getClientId(context);
String switchToDivId = tgComp.getSwitchToState();
onClick.append("TogglePanelManager.toggleOnClient('")
.append(panelId).append("',")
.append(switchToDivId==null?"null":"'" + switchToDivId + "'")
.append(");");
} else if(UITogglePanel.AJAX_METHOD.equals(switchType)) {
// Ajax
if ( !getUtils().isBooleanAttribute(component,"disabled")) {
return AjaxRendererUtils.buildOnClick(component, context, true).toString();
} else {
return "return false;";
}
} else {
// Server
//xxx by nick - denis - use org.ajax4jsf.renderkit.RendererUtils#getNestingForm(FacesContext, UIComponent)
UIForm Form= getUtils().getNestingForm(context, component);
String formId=null;
if (Form!=null){
formId = Form.getClientId(context);
}
if(formId==null) {
throw new RuntimeException("toogleControl (id=\"" + component.getClientId(context) + "\") did not find parent form.");
}
onClick.append("TogglePanelManager.toggleOnServer('")
.append(formId).append("','")
.append(component.getClientId(context)).append("',")
.append(tgComp.getSwitchToState()==null?"''":"'" + tgComp.getSwitchToState() + "'")
.append(");");
}
return onClick.toString();
}