AbstractCommandButton commandButton = (AbstractCommandButton) component;
Mode submitMode = commandButton.getMode();
StringBuffer onClick = new StringBuffer();
if (!commandButton.isDisabled()) {
HandlersChain handlersChain = new HandlersChain(context, component);
handlersChain.addInlineHandlerFromAttribute("onclick");
handlersChain.addBehaviors("click", "action");
switch (submitMode) {
case ajax:
handlersChain.addAjaxSubmitFunction();
break;
case server:
handlersChain.addInlineHandlerAsValue("RichFaces.submitForm(event.form, event.itemId)");
}
String handlerScript = handlersChain.toScript();
if (handlerScript != null) {
onClick.append(handlerScript);
}