3 Replies Latest reply on Mar 27, 2009 11:51 AM by Jay Haley

    panelMenu - wrong panelMenuGroup selected

    Jay Haley Newbie

      In this example I have two pages "Red" and "Blue". Both of these pages include the same panelMenu for navigation. If I click on the red or blue panelMenuGroup, the appropriate one is highlighted by me setting the selectedChild attribute when the red or blue page is loaded.

      My problem occurs when I click a link for the page that I'm not on and my javascript prevents me from going to the clicked page. The clicked link is highlighted, but I'm not on that page. In addition, my code that sets selectedChild has not run. Seems to be some script in the framework that's setting this. Any idea how to address this?

      navigation that's inculuded in both the Red and Blue pages

      <h:form id="navFrm">
       <rich:panelMenu expandMode="server" width="175px" selectedChild="#{navCtrl.selectedId}"
       iconItem="none" iconGroupPosition="right" iconGroupTopPosition="right">
       <rich:panelMenuGroup id="red" label="Red" action="redPage" iconCollapsed="none" iconExpanded="none" />
       <rich:panelMenuGroup id="blue" label="Blue" action="bluePage" iconCollapsed="none" iconExpanded="none" />
       </rich:panelMenu>
      </h:form>
      


      on red page
      <h:commandButton value="Cancel" onclick="return confirmBeforeExit(document.redFrm);" actionListener="#{redCtrl.cancel}" immediate="true"></h:commandButton>
      
      function confirmBeforeExit(formObj) {
      if (formIsDirty(formObj)) {
       if (! window.confirm('Your changes are unsaved? Choose Cancel to keep your changes.') ) {
       return false;
       } else {
       return true;
       }
       }
      }
      
      
      <script type="text/javascript" language="javascript">
       document.navFrm.onsubmit = function() {
       return confirmBeforeExit(document.redFrm);
       }
      </script>