I am busy writing my own JSF2 UIComponent
s and their relevant renderers. All of my UIComponent
s implements ClientBehaviorHolder
. What I don't understand is how to really render ClientBehaviorHolder
.
For example, the following code illustrates how ClientBehaviorHolder
is rendered in Mojarra.
private static void renderHandler(FacesContext context,
UIComponent component,
Collection<ClientBehaviorContext.Parameter> params,
String handlerName,
Object handlerValue,
String behaviorEventName,
String submitTarget,
boolean needsSubmit,
boolean includeExec)
throws IOException {
ResponseWriter writer = context.getResponseWriter();
String userHandler = getNonEmptyUserHandler(handlerValue);
List<ClientBehavior> behaviors = getClientBehaviors(component, behaviorEventName);
// Don't render behavior scripts if component is disabled
if ((null != behaviors) &&
(behaviors.size() > 0) &&
Util.componentIsDisabled(component)) {
behaviors = null;
}
if (params == null) {
params = Collections.emptyList();
}
String handler = null;
switch (getHandlerType(behaviors, params, userHandler, needsSubmit, includeExec)) {
case USER_HANDLER_ONLY:
handler = userHandler;
break;
case SINGLE_BEHAVIOR_ONLY:
handler = getSingleBehaviorHandler(context,
component,
behaviors.get(0),
params,
behaviorEventName,
submitTarget,
needsSubmit);
break;
case SUBMIT_ONLY:
handler = getSubmitHandler(context,
component,
params,
submitTarget,
true);
break;
case CHAIN:
handler = getChainedHandler(context,
component,
behaviors,
params,
behaviorEventName,
userHandler,
submitTarget,
needsSubmit);
break;
default:
assert(false);
}
writer.writeAttribute(handlerName, handler, null);
}
For submit handlers, Mojarra adds the mojarra.jsfcljs
javascript, UIParameter
s and other scripts. For chain handlers, jsf.util.chain
is used.
My question is:
- How does one determine if we have to render handlers in chain or a single behaviour or user specific handler?
mojarra.jsfcljs
is only unique to Mojarra. PrimeFaces have their own implementation, so does Apache Tomahawk. Question is: what doesmojarra.jsfcljs
do and what is its use? This is so that I can write one for my own? Also, where can I find the implementation ofmojarra.jsfcljs
?- What is the specification to render
ClientBehaviorHolder
?
My sincere thanks in advance.