0 Replies Latest reply on Aug 25, 2011 8:29 PM by roger manning

    Intercepting submission of a commandNavigation tab

    roger manning Newbie

      I've looked in a lot of places but can't seem to find a problem/solution that quite matches what I want so hoping someone can help.

      I have a h:form that contains many t:commandNavigation2 components. This form is part of the navigation bar at top of my site, therefore is an included xhtml file for all of my pages. When one of these tabs is clicked the associated action method returns a string which pages.xml uses to navigate the browser to the appropriate page

      What I now need to do is trigger custom actions from SOME of my pages when someone clicks on a button from this navigation bar, the kind of custom action would be dependent on which page I was on when a button from the command bar was clicked. One of these actions would be to redirect the user to a different page than the clicked on t:commandNavigation2 would direct it to

      Here's some xhtml of the nav bar, where t is http://myfaces.apache.org/tomahawk :-

      <h:form id="nav_form" onsubmit="ishmail()">
        <t:panelNavigation2 id="nav1" layout="list" itemClass="tab off" activeItemClass="tab on" openItemClass="tab selected">
          <t:commandNavigation2 id="home" action="home" immediate="true"  actionListener="#{navigationMenu.actionListener}" styleClass="tab" >
              <t:outputText value="Home" />
              <s:conversationPropagation type="none"/>
          <t:commandNavigation2 id="orderPropProfileReport" action="#{createPropProfileReport.create}" immediate="true" 
            actionListener="#{navigationMenu.actionListener}" styleClass="tab>
              <t:outputText value="Order Profile" />
              <s:conversationPropagation type="none"/>
          <t:commandNavigation2 id="order" action="#{newOrder.create}" immediate="true" actionListener="#{navigationMenu.actionListener}" 
            styleClass="tab" >
              <t:outputText value="Order Validation" />
              <s:conversationPropagation type="none"/>

      I don't want to change the way the action of each nav 'button' works if possible, so would like something I can put on the form level itself.

      I've played with putting a hidden button in the pages that need a customised action to be performed, then putting an event like onsubmit on the form that calls some javascript to click the hidden button and trigger events but even when the custom action happens and the back end bean method is called, etc. the page navigation still goes to the page indicated by the commandNavigation button that was originally clicked and not the one I want to redirect it to.

      Anybody got any suggestions how i might accomplish what I want to do?
      Some way of stopping the submit of the commandnavigation button and keeping my custom action completely in javascript would be fine too.