public void addBehaviors(String domEventName, String logicalEventName) { String name = domEventName; List<ClientBehavior> behaviorsList = getBehaviorsList(domEventName); if ((behaviorsList == null) && (logicalEventName != null)) { behaviorsList = getBehaviorsList(logicalEventName); name = logicalEventName; } if (behaviorsList == null) { return; } ClientBehaviorContext behaviorContext = ClientBehaviorContext.createClientBehaviorContext( facesContext, component, name, includeClientId ? component.getClientId(facesContext) : null, getParameters()); for (ClientBehavior clientBehavior : behaviorsList) { String behaviorScript = clientBehavior.getScript(behaviorContext); if (isNotEmpty(behaviorScript)) { if (clientBehavior.getHints().contains(ClientBehaviorHint.SUBMITTING)) { hasSubmittingBehavior = true; } handlers.add(behaviorScript); } } }
private static Object createBehaviorsChain( Object inlineHandlerValue, ClientBehaviorContext behaviorContext, List<ClientBehavior> behaviors) { boolean isChained = false; StringBuilder result = new StringBuilder(); isChained = chain(result, inlineHandlerValue, isChained); for (ClientBehavior behavior : behaviors) { isChained = chain(result, behavior.getScript(behaviorContext), isChained); if (behavior.getHints().contains(ClientBehaviorHint.SUBMITTING)) { break; } } if (result.length() == 0) { return null; } if (isChained) { result.insert(0, "return jsf.util.chain(this, event, "); result.append(")"); } return result.toString(); }
private boolean shouldAddBehavior(ClientBehaviorHolder behaviorHolder, String eventName) { if (!behaviorHolder.getEventNames().contains(eventName)) { return false; } Map<String, List<ClientBehavior>> clientBehaviorsMap = behaviorHolder.getClientBehaviors(); List<ClientBehavior> clientBehaviors = clientBehaviorsMap.get(eventName); if (clientBehaviors == null || clientBehaviors.isEmpty()) { return true; } for (ClientBehavior behavior : clientBehaviors) { Set<ClientBehaviorHint> hints = behavior.getHints(); if (hints.contains(ClientBehaviorHint.SUBMITTING)) { return false; } } return true; }
private static boolean isSubmitting(ClientBehavior behavior) { return behavior.getHints().contains(ClientBehaviorHint.SUBMITTING); }