2 Replies Latest reply on Jul 20, 2009 9:59 AM by wilczarz.wilczarz.gmail.com

    How to block ALL pages on demand?

    wilczarz.wilczarz.gmail.com

      I'm thinking of something like:


      <page view-id="*" >
        <navigation>
          <rule if="#{not systemSettings.systemAvailable}" >
            <redirect view-id="/unavailable.xhtml" />
          </rule>
        </navigation>
      </page>
      


      Where systemSettings.systemAvailable is an application-scoped expression, generally true but in special cases can be set to something like identity.getUsername().equals( someone ). You get the picture. The problem is the "*" wildcard, because this <page> node will be overriden by any other, specific one. How can I block all pages on demand, without repeating the rule for every page?

        • 1. Re: How to block ALL pages on demand?
          cash1981

          Normally you write


          <page view-id="*" required-login="true">
          </page>



          But in your case you want to match against a certain username. Rare case, because normally you will test against a specific role by using the


          s:hasRole('admin')




          or you can use the seam permission store. Anyhow, if you want to check against a specific user, you can always say that an action should be performed upon each page like this:




          <page view-id="*" >
            [snip]
            <action execute="#{someComponent.aTestToSeeWhoIsLoggedIn}/>
          </page>



          And inside that component you can do your check to see if that username is matched.
          Please note that I am not 100% sure on the syntax, but this shows how you can do it. You should double check the syntax.

          • 2. Re: How to block ALL pages on demand?
            wilczarz.wilczarz.gmail.com

            Shervin, thanks for reply. Please note that your example is not so different from mine. The page name will be matched against all page nodes from pages.xml and the closest match will be used. If you have <page viewId="*"> and <page viewId="/clients.xhtml"> in pages.xml, and you enter /clients.seam, only the second node will be used. This means that the page action would have to be included in EVERY node in pages.xml, which is exactly what I'm trying to avoid.


            Blocking all pages is, of course, a rare case. I use it when I upgrade on test environment, I like to check that everything is ok without being interrupted. Besides if anything goes wrong this would be a clean way to freeze the system.