Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-957

Mojarra 2.1.18 upgrade breaks Renderers' @ResourceDependency

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Critical
    • None
    • None
    • JSF
    • Hide

      1. deploy the attached AS7-6513-test.war
      2. open http://127.0.0.1:8080/AS7-6513-test/index.jsf
      3. click "Hello, world" button, notice an alert appears
      4. click Increment
      5. click "Hello, world" button, notice that nothing happens (and a js error occurs "myHello is not defined", as the required javascript resource is not present on the page)

      Show
      1. deploy the attached AS7-6513 -test.war 2. open http://127.0.0.1:8080/AS7-6513-test/index.jsf 3. click "Hello, world" button, notice an alert appears 4. click Increment 5. click "Hello, world" button, notice that nothing happens (and a js error occurs "myHello is not defined", as the required javascript resource is not present on the page)

    Description

      Since Mojarra 2.1.18 upgrade, the JSF doesn't render required @ResourceDependency of custom renderers on postback, if the component is bound.

      Having an renderer:

      @ResourceDependencies({ @ResourceDependency(library = "my", name = "mylib.js") })
      public class MyOutputTextRenderer extends Renderer 
      {
         @Override
         public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
            context.getResponseWriter().startElement("button", null);
            context.getResponseWriter().writeAttribute("onclick", "javascript:myHello();", null);
            context.getResponseWriter().writeText("Hello, world", null);
            context.getResponseWriter().endElement("button");
         }
      }
      

      And

      <h:form>
              <my:hello binding="#{counter.hello}"/>
      
              <h:commandButton value="Send" action="#{counter.add}" />
      </h:form>
      

      The rendered output contains the required mylib.js only in the first request, but no script element with mylib.js is rendered in the header on the page after clicking the "Send" button, thus breaking the custom component.

      Note that this happens only if the the component is using the "binding" attribute.

      @ManagedBean(name = "counter")
      @ViewScoped
      public class Counter implements Serializable
      {
         private int counter = 0;
         
         private UIOutput hello;
         
         public void setHello(UIOutput hello) {
            this.hello = hello;
         }
         
         public UIOutput getHello() {
            return this.hello;
         }
      
         public void add()
         {
            ++counter;
         }
         
         public int getCounter() {
            return counter;
         }
      }
      

      Attachments

        1. AS7-6513-test.tar
          50 kB
        2. AS7-6513-test.war
          9 kB
        3. AS7-6513-test2.zip
          14 kB

        Activity

          People

            ssilvert@redhat.com Stan Silvert
            maschmid@redhat.com Marek Schmidt
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: