ICEfaces
  1. ICEfaces
  2. ICE-7285

ace:menubar - MenuModel does not get reevaluated when re-initializing the model

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1-Beta
    • Fix Version/s: 2.1-Beta2, 3.0
    • Component/s: ACE-Components
    • Labels:
      None
    • Environment:
      All
    • Assignee Priority:
      P1

      Description

      In the Williams app they have an action menu that can be changed depending on what view or tab is shown/selected. They are using the MenuModel to programatically change the menu items. This includes adding some JavaScript to the onclick event. Upon initial load the menu's onlcik events render without any issues. When the view/tab has been changed these onclick events get removed and only the ICEfaces events remain.

      The issue seems to be in the encodeEnd method of the MenubarRenderer. When the menubar is first loaded the following gets called:

      if(menu.shouldBuildFromModel()) {
      menu.buildMenuFromModel();
      }

      When the menubar is reinitialized the above code is skipped and just the "encodeMarkup(context, menu);" is just called. This causes the model to not be built with the customized code.

        Issue Links

          Activity

          Hide
          Arran Mccullough added a comment -

          Attached is a test case that can reproduce the issue. Its not the best test case but following the steps you can see the issue. Steps to reproduce issue:

          • Load app, notice that there are three menu items in the menubar.
          • Click on the button, this should reinitialize the menubar model. It does in the backing bean but the UI isn't updated.
          • Click on the browser refesh button.
          • This should now show the three items. Clicking on each item will show a JavaScript alert.
          • Click on the update button. Now try clicking on the menu items. The JavaScript alert is no longer there since the custom on click code has not been added again.
          Show
          Arran Mccullough added a comment - Attached is a test case that can reproduce the issue. Its not the best test case but following the steps you can see the issue. Steps to reproduce issue: Load app, notice that there are three menu items in the menubar. Click on the button, this should reinitialize the menubar model. It does in the backing bean but the UI isn't updated. Click on the browser refesh button. This should now show the three items. Clicking on each item will show a JavaScript alert. Click on the update button. Now try clicking on the menu items. The JavaScript alert is no longer there since the custom on click code has not been added again.
          Hide
          Ken Fyten added a comment -

          Reminder to retest this using the BETA release code to ensure it's still present.

          Show
          Ken Fyten added a comment - Reminder to retest this using the BETA release code to ensure it's still present.
          Hide
          Deryk Sinotte added a comment -

          I'm of the opinion that there might be two separate issues here:

          1) The UI does not update from 3 -> 4 menu items when clicking the "Update" button. I can see the backing bean code being called but, as noted, the change is not reflected in the UI unless you reload the page. Looking at the response that comes back to the browser, I don't see any updates other than the ViewState:

          <partial-response>
          <changes>
          <update id="javax.faces.ViewState">1438841264988732930:7469407961588975733</update>
          <extension aceCallbackParam="validationFailed">

          {"validationFailed":false}

          </extension>
          </changes>
          </partial-response>

          This may indicate that the dynamic menu additions are somehow not being reflected in the DOM and therefore not detected as part of the DOM diff.

          2) The attached JS alerts are no longer displayed. This behaviour changes when the TestBean is changed from SessionScoped (which it is currently) to ViewScoped. When I change it to ViewScoped, the menu always has 3 items (as the update problem noted in point #1 above is still an issue), but the JS alert code is always functional.

          Show
          Deryk Sinotte added a comment - I'm of the opinion that there might be two separate issues here: 1) The UI does not update from 3 -> 4 menu items when clicking the "Update" button. I can see the backing bean code being called but, as noted, the change is not reflected in the UI unless you reload the page. Looking at the response that comes back to the browser, I don't see any updates other than the ViewState: <partial-response> <changes> <update id="javax.faces.ViewState">1438841264988732930:7469407961588975733</update> <extension aceCallbackParam="validationFailed"> {"validationFailed":false} </extension> </changes> </partial-response> This may indicate that the dynamic menu additions are somehow not being reflected in the DOM and therefore not detected as part of the DOM diff. 2) The attached JS alerts are no longer displayed. This behaviour changes when the TestBean is changed from SessionScoped (which it is currently) to ViewScoped. When I change it to ViewScoped, the menu always has 3 items (as the update problem noted in point #1 above is still an issue), but the JS alert code is always functional.
          Hide
          Arturo Zambrano added a comment -

          Fixed at revision 25810...

          Originally, the component didn't support modifications to the menu when building from model. The menu only was built at the beginning and it wasn't possible to update it. Code was added to remove this condition and re-build the menu at every request if its 'model' property is not null. However, this change caused a problem with having duplicate id's since the previous generated children of the menu weren't being removed before re-creating the menu. This was temporarily solved by calling getchildren().removeAll(getChildren()) from the AbstractMenu class before the new children were added. However, it was later found out that the UIComponentBase class subclasses the java.util.ArrayList class used to keep the list of children and adds some custom logic. This was causing, in some cases, the same problem with the duplicate id's since not all children were being removed. Eventually, this was solved by calling instead getChildren().clear(), which directly removes all contents of the list without any custom evaluations.

          Show
          Arturo Zambrano added a comment - Fixed at revision 25810... Originally, the component didn't support modifications to the menu when building from model. The menu only was built at the beginning and it wasn't possible to update it. Code was added to remove this condition and re-build the menu at every request if its 'model' property is not null. However, this change caused a problem with having duplicate id's since the previous generated children of the menu weren't being removed before re-creating the menu. This was temporarily solved by calling getchildren().removeAll(getChildren()) from the AbstractMenu class before the new children were added. However, it was later found out that the UIComponentBase class subclasses the java.util.ArrayList class used to keep the list of children and adds some custom logic. This was causing, in some cases, the same problem with the duplicate id's since not all children were being removed. Eventually, this was solved by calling instead getChildren().clear(), which directly removes all contents of the list without any custom evaluations.
          Hide
          Brad Kroeger added a comment -

          We assigned id's to all of our submenus and now, when the ace:menubar is dynamically updated, the submenu values are not displayed, only the image is there.

          Update the poc, in the first submenu you should find a selection for print that will dynamically add a print menuitem. Afterwards, you will see the submenu value(label) disappear.

          Show
          Brad Kroeger added a comment - We assigned id's to all of our submenus and now, when the ace:menubar is dynamically updated, the submenu values are not displayed, only the image is there. Update the poc, in the first submenu you should find a selection for print that will dynamically add a print menuitem. Afterwards, you will see the submenu value(label) disappear.
          Hide
          Arturo Zambrano added a comment -

          This has been fixed by a preliminary generator change related to ICE-7321. The new approach will be improved, but the basic idea seems to fix this particular problem.

          Show
          Arturo Zambrano added a comment - This has been fixed by a preliminary generator change related to ICE-7321 . The new approach will be improved, but the basic idea seems to fix this particular problem.

            People

            • Assignee:
              Arturo Zambrano
              Reporter:
              Arran Mccullough
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: