Jsf 根据用户类型呈现的主页

Jsf 根据用户类型呈现的主页,jsf,seam,richfaces,Jsf,Seam,Richfaces,我使用以下代码在登录时重定向到我的主页。。。现在我想更进一步,添加一个逻辑,根据用户类型重定向到不同的页面 例如:如果用户类型是employee,那么我应该重定向到employeehome.xhtml等等。。。这可能吗 <page xmlns="http://jboss.com/products/seam/pages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://j

我使用以下代码在登录时重定向到我的主页。。。现在我想更进一步,添加一个逻辑,根据用户类型重定向到不同的页面

例如:如果用户类型是employee,那么我应该重定向到employeehome.xhtml等等。。。这可能吗

<page xmlns="http://jboss.com/products/seam/pages"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.2.xsd">

<navigation from-action="#{identity.login}">
    <rule if="#{identity.loggedIn}">
        <redirect view-id="/Home.xhtml" />
    </rule>
</navigation>


我想您有一个login.xhtml页面,用户可以从该页面登录

然后可以创建一个login.page.xml页面,其中包含一些导航规则。例如:

     <navigation from-action='#{identity.login}'>
        <rule if="#{identity.loggedIn and s:hasRole('management')}">
            <redirect view-id="/management/home.xhtml"/>
        </rule>
        <rule if="#{identity.loggedIn and s:hasRole('upload')}">
            <redirect view-id="/secure/upload.xhtml"/>
        </rule>
        <rule if="#{identity.loggedIn and (s:hasRole('sss') or s:hasRole('sssmgmnt'))}">
            <redirect view-id="/secure/sss/home.xhtml"/>
        </rule>
        <rule if="#{identity.loggedIn}">
            <redirect view-id="/secure/home.xhtml"/>
        </rule>  
    </navigation>

接下来,您可以限制页面,这样只有具有正确角色的用户才能访问该页面。在my pages.xml中,我有以下几行:

<page view-id="/secure/upload.xhtml" login-required="true">
    <restrict>#{s:hasRole('upload')}</restrict>
</page>

#{s:hasRole('upload')}