public static void addEventOption(FacesContext context, UIComponent component, Map<String, Object> options, String eventName) {
HandlersChain handlersChain = new HandlersChain(context, component);
handlersChain.addInlineHandlerFromAttribute(ON + eventName);
handlersChain.addBehaviors(eventName);
// handlersChain.addAjaxSubmitFunction();
String handler = handlersChain.toScript();
if (handler != null) {
options.put(ON + eventName, new JSFunctionDefinition(JSReference.EVENT).addToBody(handler));