ICEfaces
  1. ICEfaces
  2. ICE-6607

Menu item action listener called multiple times

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.1
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      N/A

      Description

      The action listener of a menu item under a MenuItems component is being called multiple time, increasing with each click.

        Activity

        yip.ng created issue -
        yip.ng made changes -
        Field Original Value New Value
        Assignee Yip Ng [ yip.ng ]
        yip.ng made changes -
        Salesforce Case []
        Description The action listener of a menu item under a MenuItems component are being called multiple time, increasing with each click.
        The action listener of a menu item under a MenuItems component is being called multiple time, increasing with each click.
        Hide
        yip.ng added a comment -

        Seems the event is queued only once per click. Yet the event listener is called multiple times.

        Show
        yip.ng added a comment - Seems the event is queued only once per click. Yet the event listener is called multiple times.
        Hide
        yip.ng added a comment -

        From Mark:

        Try investigating MenuItems.setParentsRecursive(UIComponent, List,ActionListener[], MethodBinding, MethodBinding). It could be that the code which tries to remove the previous action/actionListener might not be doing the job anymore, so that then the add code would be adding redundant ActionListener references, which would each fire from the one ActionEvent. This might be due JSF 2 doing state saving on the ActionListener references, so that a direct reference comparison is now incorrect.

        Show
        yip.ng added a comment - From Mark: Try investigating MenuItems.setParentsRecursive(UIComponent, List,ActionListener[], MethodBinding, MethodBinding). It could be that the code which tries to remove the previous action/actionListener might not be doing the job anymore, so that then the add code would be adding redundant ActionListener references, which would each fire from the one ActionEvent. This might be due JSF 2 doing state saving on the ActionListener references, so that a direct reference comparison is now incorrect.
        Hide
        yip.ng added a comment -

        removeActionListener() ultimately calls java.util.List#remove, which uses java.lang.Object#equals to locate the listener to delete.

        It seems that the MenuItems component object and its attached listener change reference every time, as if they were re-created every time. Thus MenuItem.removeActionListener() can't locate any listener to delete and does nothing. And addActionListener() keeps adding multiple references to the same listener.

        So, do we then have to override javax.faces.event.MethodExpressionActionListener with a different equals() method?

        Show
        yip.ng added a comment - removeActionListener() ultimately calls java.util.List#remove, which uses java.lang.Object#equals to locate the listener to delete. It seems that the MenuItems component object and its attached listener change reference every time, as if they were re-created every time. Thus MenuItem.removeActionListener() can't locate any listener to delete and does nothing. And addActionListener() keeps adding multiple references to the same listener. So, do we then have to override javax.faces.event.MethodExpressionActionListener with a different equals() method?
        Hide
        yip.ng added a comment -

        From Mark:

        How about we call ActionListener[] getActionListeners(), and if there's anything at all in the array, then don't add the ActionListener, otherwise add it. This should keep us from duplicating our adding, and also keep the MenuItems from stomping over any ActionListener that the MenuItem children may have had added to them by the bean code that created them.

        Show
        yip.ng added a comment - From Mark: How about we call ActionListener[] getActionListeners(), and if there's anything at all in the array, then don't add the ActionListener, otherwise add it. This should keep us from duplicating our adding, and also keep the MenuItems from stomping over any ActionListener that the MenuItem children may have had added to them by the bean code that created them.
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #24004 Thu Feb 24 15:21:59 MST 2011 yip.ng ICE-6607: Menu item action listener called multiple times.
        Files Changed
        Commit graph MODIFY /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/menubar/MenuItems.java
        Ken Fyten made changes -
        Salesforce Case []
        Affects Version/s 2.0.0 [ 10230 ]
        Affects Version/s 2.0-Beta2 [ 10242 ]
        Hide
        yip.ng added a comment -

        Revision: 24004


        Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/menubar/MenuItems.java

        Show
        yip.ng added a comment - Revision: 24004 Modified : /icefaces2/trunk/icefaces/compat/components/src/main/java/com/icesoft/faces/component/menubar/MenuItems.java
        yip.ng made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            yip.ng
            Reporter:
            yip.ng
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: