我很难回答这个问题,因为我根本不明白。不过我会试着猜猜你在问什么。
您有一个页面,即:/somePage.xhtml,并且在该页面内您包含其他一些页面。
我倾向于在pages.xml 中编写所有页面导航。我喜欢把所有东西都放在一个地方,因为它让事情变得更干净、更容易维护。
您也可以在pages.xml 文件中使用通配符。
所以你可以做这样的事情。
<page login-required="true" view-id="/admin/*">
<restrict>#{s:hasRole('orgadmin') or s:hasRole('sysadmin')}</restrict>
<navigation from-action="#{userAdmin.editUser}">
<redirect view-id="/admin/create_user.xhtml" />
</navigation>
<navigation from-action="#{applicationProcessAdmin.saveScheme}">
<rule if-outcome="failure">
<redirect view-id="/admin/processes.xhtml" />
</rule>
</navigation>
</page>
在上面的示例中,我使用通配符表示从 /admin/* 发生的所有使用某些特定操作的导航都应该重定向到我拥有的某个页面。
你也可以对页面非常具体
<page login-required="true" view-id="/officer/admin/contacts.xhtml">
<begin-conversation join="true" />
<navigation from-action="#{officerAdmin.saveContact}">
<redirect/>
</navigation>
</page>
如果这对您没有帮助,您需要更好地澄清您的问题。
更新
尝试改变你的
<page view-id="/*" login-required="true">
<navigation>
<rule if="#{myBean.readyToSee}">
<redirect view-id="/see-contat.xhtml"/>
</rule>
</navigation>
</page>
改为这个
<page view-id="/*" login-required="true">
<navigation from-action="#{myBean.readyToSee}">
<rule if="#{myBean.readyToSee}">
<redirect view-id="/see-contat.xhtml"/>
</rule>
</navigation>
</page>
更新 2
所有导航都失败了吗?还是只有一些?
尝试删除页面视图上的 /* 并仅替换为 *
如果你这样做会起作用:
@Name("myBean")
public class MyBean {
public String doSomething() {
return "success";
}
}
现在来自您的 xhtml(无论它来自哪个包含页面)
<!-- Depending on what button you are using, <h:form> is mandatory -->
<h:form>
<h:commandButton value="TEST" action="#{myBean.doSomething}" />
</h:form>
在你的页面中 xml
<page view-id="*">
<navigation from-action="#{myBean.doSomething}">
<rule if-outcome="success">
<redirect view-id="/test.xhtml" />
</rule>
</navigation>
</page>
上述方法将起作用。如果没有,则错误位于代码中的其他位置。