javaserverfaces-spec-public
  1. javaserverfaces-spec-public
  2. JAVASERVERFACES_SPEC_PUBLIC-1162

Dynamically created ClientBehaviors do not call addComponentResource

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1
    • Fix Version/s: None
    • Component/s: Ajax/JavaScript
    • Labels:
      None
    • 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)

        Activity

        Hide
        kennardconsulting added a comment -

        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?

        Show
        kennardconsulting added a comment - 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?
        Hide
        kennardconsulting added a comment -

        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?

        Show
        kennardconsulting added a comment - 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?
        Hide
        Ed Burns added a comment -

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

        Show
        Ed Burns added a comment - Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

          People

          • Assignee:
            Unassigned
            Reporter:
            kennardconsulting
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: