3 Replies Latest reply on Dec 3, 2007 9:10 AM by dmitriy.lapko

    Preprocessing constraints for pages

    dmitriy.lapko

      Is there any convenient ways to check some constraints before processing the request to any view? Something like but not so bounded to access rights. Something like navigation rule but before execute action phase.

      Simple example, and ALL needs it:
      I want to redirect already loginned user to welcome page, if he tries to visit login page. No error messages, no warnings.

      I don't want to create special user rights for this or add page action which will check if user is already loginned and then process special outcome from this action - this inforces me to do something that can break my previous logic.

      So, I just want to add to some pre-condition with navigation which should be done if this condition is true.
      Like:

      <page view-id="/item.xhtml">
       <navigation>
       <rule if-before="#{indentity.loggedIn}">
       <redirect view-id="/welcome.html"/>
       </rule>
      </page>
      


      How can I do it in Seam 2.0 GA?




        • 1. Re: Preprocessing constraints for pages
          pmuir

          You should use restrict.

          • 2. Re: Preprocessing constraints for pages
            dmitriy.lapko

            But restrict will raise an exception? org.jboss.seam.security.AuthorizationException? But I don't need it.

            • 3. Re: Preprocessing constraints for pages
              dmitriy.lapko

              Pete, can you please explain me, how can I customize reaction on org.jboss.seam.security.AuthorizationException for different situations?

              For example, for login.seam I need redirect to welcome.xhtml if user is already loginned, for item.seam I need redirect to list.seam if parameter itemId is absent in request and so on.

              For now I see only one configuration without considering where this exception occured:

              <exception class="org.jboss.seam.security.AuthorizationException">
               <redirect>
               <message severity="ERROR">You don't have permission to do this.</message>
               </redirect>
               </exception>


              Did I understand you answer correctly? Or you meant something else?