javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2162

preRenderView listener called two many times, more and more

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.2
    • Fix Version/s: 2.1.12, 2.2.0-m05
    • Component/s: None
    • Labels:
      None
    • Environment:

      Tomcat 7 + CDI (Weld) 1.1.2 + Hibernate Validator 4.2.0

      Description

      If in my page, I declare this event handler :

      <f:metadata>
      <f:event type="preRenderView" listener="#

      {myBean.init}

      "/>
      </f:metadata>

      and I do Ajax requests in the same view, the handler (init) is called for each ajax request (ok), but as many times as the number of Ajax requests made since the initial display of the page. For instance, if it is the 10th ajax request, for this request the handler will be called 10 times (in one RENDER VIEW phase); for the next request, if will be calles 11th times.

      I've found a workaround : if I add <f:viewParam name="dummy"/> just before the event declaration, the preRenderView event is only fired once (for each ajax request)

        Activity

        Hide
        micharg added a comment - - edited

        Same problem here if the init() method accepts an argument...it is called twice if the page contains av <f:ajax> event. The workourd (<f:viewParam name="dummy"/>) proposed on the description hasn't worked for me..

        This doesn't work:
        <f:metadata>
        <f:event type="preRenderView" listener="#

        {myBean.init(param.foo)}

        "/>
        </f:metadata>

        For whomever needs a solution use this:

        <f:metadata>
        <f:viewParam name="foo" value="#

        {myBean.foo}

        " />
        <f:event type="preRenderView" listener="#

        {myBean.init()}

        "/>
        </f:metadata>

        Show
        micharg added a comment - - edited Same problem here if the init() method accepts an argument...it is called twice if the page contains av <f:ajax> event. The workourd (<f:viewParam name="dummy"/>) proposed on the description hasn't worked for me.. This doesn't work: <f:metadata> <f:event type="preRenderView" listener="# {myBean.init(param.foo)} "/> </f:metadata> For whomever needs a solution use this: <f:metadata> <f:viewParam name="foo" value="# {myBean.foo} " /> <f:event type="preRenderView" listener="# {myBean.init()} "/> </f:metadata>
        Hide
        oversteer added a comment -

        I decided to start counting ajax events as page hits (the world has changed, right?) and was
        seeing some bizarre results, and this was why. The f:viewparam name="dummy" has fixed it for
        me, so thanks to DenisGL for reporting this and the workaround.

        9 votes now, fingers crossed that this gets some attention soon!

        Show
        oversteer added a comment - I decided to start counting ajax events as page hits (the world has changed, right?) and was seeing some bizarre results, and this was why. The f:viewparam name="dummy" has fixed it for me, so thanks to DenisGL for reporting this and the workaround. 9 votes now, fingers crossed that this gets some attention soon!
        Hide
        Manfred Riem added a comment -

        Tests to verify this is no longer an issue

        Show
        Manfred Riem added a comment - Tests to verify this is no longer an issue
        Hide
        Manfred Riem added a comment -

        Applied to 2.1 branch,

        svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2162, r=rogerk, Tests to verify this is no longer an issue"
        Adding test\agnostic\ajax\src\main\java\com\sun\faces\test\agnostic\ajax\Issue2162Bean.java
        Adding test\agnostic\ajax\src\main\webapp\issue2162.xhtml
        Adding test\agnostic\ajax\src\test\java\com\sun\faces\test\agnostic\ajax\Issue2162IT.java
        Transmitting file data ...
        Committed revision 10401.

        Show
        Manfred Riem added a comment - Applied to 2.1 branch, svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2162 , r=rogerk, Tests to verify this is no longer an issue" Adding test\agnostic\ajax\src\main\java\com\sun\faces\test\agnostic\ajax\Issue2162Bean.java Adding test\agnostic\ajax\src\main\webapp\issue2162.xhtml Adding test\agnostic\ajax\src\test\java\com\sun\faces\test\agnostic\ajax\Issue2162IT.java Transmitting file data ... Committed revision 10401.
        Hide
        Manfred Riem added a comment -

        Applied to 2.2 trunk,

        svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2162, r=rogerk, Tests to verify this is no longer an issue"
        Adding test\agnostic\ajax\src\main\java\com\sun\faces\test\agnostic\ajax\Issue2162Bean.java
        Adding test\agnostic\ajax\src\main\webapp\issue2162.xhtml
        Adding test\agnostic\ajax\src\test\java\com\sun\faces\test\agnostic\ajax\Issue2162IT.java
        Transmitting file data ...
        Committed revision 10402.

        Show
        Manfred Riem added a comment - Applied to 2.2 trunk, svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2162 , r=rogerk, Tests to verify this is no longer an issue" Adding test\agnostic\ajax\src\main\java\com\sun\faces\test\agnostic\ajax\Issue2162Bean.java Adding test\agnostic\ajax\src\main\webapp\issue2162.xhtml Adding test\agnostic\ajax\src\test\java\com\sun\faces\test\agnostic\ajax\Issue2162IT.java Transmitting file data ... Committed revision 10402.
        Hide
        oversteer added a comment -

        Hi, I've just downloaded 2.1.12 and tested this fix which I noticed in the 2.1.12 release notes
        listed as a resolved problem. After removing the f:viewParam name="dummy" I'm afraid that I'm seeing
        the preRenderView listener firing increasing numbers of times, with each ajax request the listener
        fires an additional time. The workaround still works ok.

        So this doesn't seem to be fixed to me. I can confirm that the mojarra upgrade worked ok, I'm
        seeing 2.1.12 in the server logs and also specified this version in my pom.xml.

        Can anyone else confirm that this problem still exists?

        Regards,
        Brendan Healey.

        Show
        oversteer added a comment - Hi, I've just downloaded 2.1.12 and tested this fix which I noticed in the 2.1.12 release notes listed as a resolved problem. After removing the f:viewParam name="dummy" I'm afraid that I'm seeing the preRenderView listener firing increasing numbers of times, with each ajax request the listener fires an additional time. The workaround still works ok. So this doesn't seem to be fixed to me. I can confirm that the mojarra upgrade worked ok, I'm seeing 2.1.12 in the server logs and also specified this version in my pom.xml. Can anyone else confirm that this problem still exists? Regards, Brendan Healey.
        Hide
        ulrich.gratz added a comment -

        Hi Brendan,
        I have the same issue here. We are working on version 2.1 and the proble still occurs.
        So I can unfortunatley only confirm your observation

        Best regards,
        Ulrich

        Show
        ulrich.gratz added a comment - Hi Brendan, I have the same issue here. We are working on version 2.1 and the proble still occurs. So I can unfortunatley only confirm your observation Best regards, Ulrich
        Hide
        Manfred Riem added a comment -

        If this is still an issue, please file a new issue with a simple WAR file reproducing the problem.

        Show
        Manfred Riem added a comment - If this is still an issue, please file a new issue with a simple WAR file reproducing the problem.
        Hide
        balusc added a comment -
        Show
        balusc added a comment - This issue is re-reported in http://java.net/jira/browse/JAVASERVERFACES-2719

          People

          • Assignee:
            Manfred Riem
            Reporter:
            DenisGL
          • Votes:
            9 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: