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

        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.
        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

          People

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

            Dates

            • Created:
              Updated:
              Resolved: