[JAVASERVERFACES_SPEC_PUBLIC-1162] Dynamically created ClientBehaviors do not call addComponentResource Created: 07/Feb/13  Updated: 13/Aug/14

Status: Open
Project: javaserverfaces-spec-public
Component/s: Ajax/JavaScript
Affects Version/s: 2.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: kennardconsulting Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Both Mojarra and MyFaces 2.1.x implementations behave the same



 Description   
  • If I dynamically create UIComponents using the new Application.createComponent( context, componentType, rendererType ), I find they automatically add any dependent resources (JS/CSS) to the h:head. This is fantastic.
  • If I dynamically create ClientBehaviours using Application.createBehavior( id ), no dependent resources get added.

Am I supposed to add such resources manually? For example:

UIOutput js = new UIOutput();
js.setRendererType("javax.faces.resource.Script");
js.getAttributes().put("library", "mylibrary");
js.getAttributes().put("name", "bar.js");

FacesContext context = FacesContext.getCurrentInstance();
context.getViewRoot().addComponentResource(context, js, "head");

If so, how am I supposed to know what they are? For example, if I am dynamically adding an AjaxBehavior the exact name of the JavaScript file depends on which JSF implementation I am using.

Also logged as https://issues.apache.org/jira/browse/MYFACES-3610 (but got no response, so I'm trying it as a spec issue)



 Comments   
Comment by kennardconsulting [ 07/Feb/13 ]

The MyFaces team have indicated this may be a bug in the spec:

"the reason it does not work is because javax.faces.component.behavior.AjaxBehavior does not have @ResourceDependency attached"
https://issues.apache.org/jira/browse/MYFACES-3610

Could you please discuss?

Comment by kennardconsulting [ 08/Feb/13 ]

I checked javax.faces.component.behavior.AjaxBehaviour.java in the latest 2.2 snapshot...

https://maven.java.net/content/repositories/snapshots/javax/faces/javax.faces-api/2.2-SNAPSHOT/javax.faces-api-2.2-20130207.091549-141-sources.jar

...and it doesn't appear to be annotated there either?

Comment by Ed Burns [ 01/Aug/14 ]

Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

Generated at Tue Dec 06 03:04:00 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.