ICEfaces
  1. ICEfaces
  2. ICE-6665

MenuBar and menuPopup not working with Mojarra 2.1.1-b02

    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:
      Mojarra 2.1.1-b02 and ICEfaces 2 Compat menuBar and menuPopup

      Description

      When doing a postback with a form that contains a menuBar or menuPopup, the state restoration code is throwing a NPE.

        Activity

        Hide
        Mark Collette added a comment -

        This can only be duplicated by using svn revision 24115, from ICE-6649, of: icefaces2/lib/jsf-api.jar and jsf-impl.jar. The next revision of those jars in our svn contains the earlier Mojarra 2.1.1-b01 code, which works fine.

        From Ted's analysis of the Mojarra code, the problem is that on state restore there exists state for which no component can be found, and the code assumes the component will be found, and throws a NPE. A trivial solution would be to not worry about having extra state with no corresponding component. But, since there's no guarantee that a change of that nature will happen, we'll need to see what we can do on our end.

        So, we know that Mojarra is saving state for components that do not exist in the view upon restore. And from the clientIds, they are temporary helper components that the MenuItemRenderer creates to accomplish its rendering. The exception is not thrown by the selectInputDate component, which also dynamically adds helper components to the view.

        Show
        Mark Collette added a comment - This can only be duplicated by using svn revision 24115, from ICE-6649, of: icefaces2/lib/jsf-api.jar and jsf-impl.jar. The next revision of those jars in our svn contains the earlier Mojarra 2.1.1-b01 code, which works fine. From Ted's analysis of the Mojarra code, the problem is that on state restore there exists state for which no component can be found, and the code assumes the component will be found, and throws a NPE. A trivial solution would be to not worry about having extra state with no corresponding component. But, since there's no guarantee that a change of that nature will happen, we'll need to see what we can do on our end. So, we know that Mojarra is saving state for components that do not exist in the view upon restore. And from the clientIds, they are temporary helper components that the MenuItemRenderer creates to accomplish its rendering. The exception is not thrown by the selectInputDate component, which also dynamically adds helper components to the view.
        Hide
        Mark Collette added a comment -

        Analysis of the menu and calendar code showed that the calendar adds the helper components to the view, marks them transient, and gives them ids. The MenuItem code makes helper link, image and text components, but instead does a hack of not adding them to the view and instead making the top of that component sub-tree set it's parent to the MenuItem, so that the components will render thinking they're in the component tree without actually being. Changing the code so that they are actually added to the component tree, and given appropriate ids and marked transient solved it.

        Basically, some component event listener used by the state saving code, was being told about these pseudo-treed components, while they were not actually being fully state saved, since recursing the tree wouldn't find them. The NPE was from the mismatch of the two parts of state saving not being in sync.

        Show
        Mark Collette added a comment - Analysis of the menu and calendar code showed that the calendar adds the helper components to the view, marks them transient, and gives them ids. The MenuItem code makes helper link, image and text components, but instead does a hack of not adding them to the view and instead making the top of that component sub-tree set it's parent to the MenuItem, so that the components will render thinking they're in the component tree without actually being. Changing the code so that they are actually added to the component tree, and given appropriate ids and marked transient solved it. Basically, some component event listener used by the state saving code, was being told about these pseudo-treed components, while they were not actually being fully state saved, since recursing the tree wouldn't find them. The NPE was from the mismatch of the two parts of state saving not being in sync.
        Hide
        Mark Collette added a comment -

        A much more complicated issue arose when handling MenuItems. With MenuItems, its children MenuItem objects are taken from a bean, and pseudo added to the component tree with the same parenting technique. But simply adding them to the view and marking them transient was not sufficient, because those MenuItem components exist longer than a single lifecycle, and exist as long as the beean does. So there were complications with them being handled as transient, since they do in fact persist longer. Special care had to be taken to remove them from the view, and to also handle the transient link, image and text components that are not being added to them.

        Show
        Mark Collette added a comment - A much more complicated issue arose when handling MenuItems. With MenuItems, its children MenuItem objects are taken from a bean, and pseudo added to the component tree with the same parenting technique. But simply adding them to the view and marking them transient was not sufficient, because those MenuItem components exist longer than a single lifecycle, and exist as long as the beean does. So there were complications with them being handled as transient, since they do in fact persist longer. Special care had to be taken to remove them from the view, and to also handle the transient link, image and text components that are not being added to them.
        Hide
        Mark Collette added a comment -

        Also, since the NPE was tied to visitTree, has to invesitgate the effects of ICE-4993 which put custom invokeOnComponent methods in MenuBar and MenuItemBase.

        Show
        Mark Collette added a comment - Also, since the NPE was tied to visitTree, has to invesitgate the effects of ICE-4993 which put custom invokeOnComponent methods in MenuBar and MenuItemBase.
        Hide
        Mark Collette added a comment -

        Committed all the changes to now actually add the helper link, image and text components, as well as the MenuItems children, into the component tree.

        Subversion 24142

        Show
        Mark Collette added a comment - Committed all the changes to now actually add the helper link, image and text components, as well as the MenuItems children, into the component tree. Subversion 24142

          People

          • Assignee:
            Mark Collette
            Reporter:
            Mark Collette
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: