3 Replies Latest reply on Feb 14, 2011 9:28 AM by mmulligan03

    page view-id not equal to

    mmulligan03

      For every page except one I want a action to be executed with every request sent to the server. 


      for instance:
      I have a page called home.xhtml and I don't want the action to be executed when a request comes in for this page but for every other page the action should get executed.


      Is there any way here to say if the view-id is not /home.xhtml ?


      <page view-id="*" >
           <action execute="#{authenticator.setCookie()}"  />
           <navigation>
               <rule if-outcome="home">
                   <redirect view-id="/home.xhtml" />
               </rule>
          </navigation>
      </page>



        • 1. Re: page view-id not equal to
          amitev

          You can use the if attribute of <action> tag. Like this:


          <action execute="#{authenticator.setCookie()}" 
          if="#{!'home.xhtml'.equals(facesContext.viewRoot.viewId)}" />
          

          • 2. Re: page view-id not equal to
            mmulligan03

            I have tried


            <action execute="#{authenticator.setCookie()}" 
                         if="#{!'/home.xhtml'.equals(facesContext.viewRoot.viewId)}" />



            and


            <action execute="#{authenticator.setCookie()}" 
                         if="#{!facesContext.viewRoot.viewId.equals('/home.xhtml')}" />




            Neither works, I added the / because when I print out facesContext.getViewRoot().getViewId() in the method the view is /home.xhtml

            • 3. Re: page view-id not equal to
              mmulligan03

              Never-mind my last post, I didn't realize that something else was calling the same method when the page loaded... Your suggestion did work, thank you for the post.