MyFaces Core
  1. MyFaces Core
  2. MYFACES-2480

@ResourceDependencies does not work on custom behaviors

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-alpha
    • Fix Version/s: 2.0.0-beta-2
    • Component/s: None
    • Labels:
      None

      Description

      I created a simple custom behavior, that requires (more ships ) a simple JS file. On the RI (run-time testing) it works. Not so on myfaces2 trunk

      My class:
      package net.wessendorf;

      import java.util.EnumSet;
      import java.util.Set;

      import javax.faces.application.ResourceDependencies;
      import javax.faces.application.ResourceDependency;
      import javax.faces.component.behavior.ClientBehaviorBase;
      import javax.faces.component.behavior.ClientBehaviorContext;
      import javax.faces.component.behavior.ClientBehaviorHint;
      import javax.faces.component.behavior.FacesBehavior;

      @FacesBehavior("net.wessendorf.Confirm")
      @ResourceDependencies(

      { @ResourceDependency(name="tester.js", library="wessi", target="head") }

      )
      public class TestConfirmBehavior extends ClientBehaviorBase
      {

      @Override
      public String getScript(ClientBehaviorContext behaviorContext)

      { return "return confirm('Really')"; }

      @Override
      public Set<ClientBehaviorHint> getHints()

      { return EnumSet.of(ClientBehaviorHint.SUBMITTING); }

      }

      taglib.xml file:
      <facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
      version="2.0">

      <namespace>http://wessendorf.net/behavior</namespace>
      <tag>
      <tag-name>confirm</tag-name>
      <behavior>
      <behavior-id>net.wessendorf.Confirm</behavior-id>
      </behavior>
      </tag>
      </facelet-taglib>

      tester.js file:
      test = function()

      { alert('HALLO JSF2'); }

        Activity

        Hide
        Ingo Hofmann added a comment -

        I have seen that you committed a fix for this with number 903211.

        I was working on this issue last week and wrote the attached test that doesn't run green with your fix. A similar page configuration to your example doesn't work either.
        Reason: If the ResourceDependency has a non-null "target" attribute, the resource will not be added. The ResourceDependency's spec Javadoc doesn't mention it in the algorithm description, but in the description of "target", that you are supposed to invoke UIViewRoot.addComponentResource(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String) if "target" is not null.

        Attached patch contains a test case for this and the missing line in ApplicationImpl._handleAttachedResourceDependency().

        Show
        Ingo Hofmann added a comment - I have seen that you committed a fix for this with number 903211. I was working on this issue last week and wrote the attached test that doesn't run green with your fix. A similar page configuration to your example doesn't work either. Reason: If the ResourceDependency has a non-null "target" attribute, the resource will not be added. The ResourceDependency's spec Javadoc doesn't mention it in the algorithm description, but in the description of "target", that you are supposed to invoke UIViewRoot.addComponentResource(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String) if "target" is not null. Attached patch contains a test case for this and the missing line in ApplicationImpl._handleAttachedResourceDependency().
        Hide
        Matthias Weßendorf added a comment -

        Ingo,

        I know: http://svn.apache.org/viewvc?view=revision&revision=903221
        needed a quick fix...

        Thanks for the patch, will review it.

        Show
        Matthias Weßendorf added a comment - Ingo, I know: http://svn.apache.org/viewvc?view=revision&revision=903221 needed a quick fix... Thanks for the patch, will review it.
        Hide
        Matthias Weßendorf added a comment -

        annotation handling done in revs: "903211" and "903221"
        target and new test by Ingo Hofmann. Thanks Ingo

        Show
        Matthias Weßendorf added a comment - annotation handling done in revs: "903211" and "903221" target and new test by Ingo Hofmann. Thanks Ingo

          People

          • Assignee:
            Matthias Weßendorf
            Reporter:
            Matthias Weßendorf
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development