2 Replies Latest reply on Jul 20, 2009 9:59 AM by Tomasz Wilczynski

    How to block ALL pages on demand?

    Tomasz Wilczynski Newbie

      I'm thinking of something like:

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

      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?
          Shervin Asgari Master

          Normally you write

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

          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


          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="*" >
            <action execute="#{someComponent.aTestToSeeWhoIsLoggedIn}/>

          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?
            Tomasz Wilczynski Newbie

            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.