Joe*_*erg 3 navigation restrictions java-ee-6 jsf-2
我学会了使用 Java 和 Seam(以及 JSF 1.2)构建 Web 应用程序
但现在我正在使用纯 Java EE 6 和 JSF (Mojara 2.0.9) - 没有任何额外的框架。
在Seam中我使用了forindex.xhtml限制index.page.xml:
<restrict>#{authorizationManager.isAdmin()}</restrict>
Run Code Online (Sandbox Code Playgroud)
有没有像page.xml一样的功能?
并且:
我还使用了index.page.xml拨打一些电话,例如:
<action execute="#{indexController.doSomething()}" on-postback="false"/>
Run Code Online (Sandbox Code Playgroud)
@PostConstruct现在是在控制器中为 .xhtml 执行此操作的唯一机会吗?
另外我如何在没有 的情况下做这样的事情page.xml?
<navigation>
<rule if-outcome="OK">
<redirect view-id="/pages/index.xhtml" />
</rule>
</navigation>
Run Code Online (Sandbox Code Playgroud)
在我看来,纯JavaEE的工作方式完全不同?
(你不必向我发送完整的代码,只需给我我必须谷歌搜索的关键词,谢谢!)
在Seam中,我使用index.xhtml和index.page.xml进行限制:
Run Code Online (Sandbox Code Playgroud)<restrict>#{authorizationManager.isAdmin()}</restrict>有没有像page.xml一样的功能?
标准 JSF 不提供任何内置的身份验证/授权设施。所有这些都可以从“原始”Servlet API 或 Spring Security 等第三方框架中使用。
至于“原始”Servlet API 设施,<security-constraint>inweb.xml很接近。您只能限制全局 URL 模式,例如/app/*,而不能限制每个页面或每个操作。
我还使用 index.page.xml 进行一些调用,例如:
Run Code Online (Sandbox Code Playgroud)<action execute="#{indexController.doSomething()}" on-postback="false"/>现在是在 .xhtml 控制器中使用 @PostConstruct 进行此操作的唯一机会吗?
<f:event>XHTML 页面本身的内容很接近:
<f:event type="preRenderView" listener="#{indexController.doSomething}" />
Run Code Online (Sandbox Code Playgroud)
至于on-postback替换,请检查是否可以在回发时禁用 f:event type="preRenderView" 侦听器?。
另外我如何在没有 page.xml 的情况下做这样的事情?
Run Code Online (Sandbox Code Playgroud)<navigation> <rule if-outcome="OK"> <redirect view-id="/pages/index.xhtml" /> </rule> </navigation>在我看来,纯JavaEE的工作方式完全不同?
JSF 2.0 支持隐式导航,这完全<navigation-rule>是faces-config.xml多余的。返回的结果将被隐式地视为目标视图 ID。faces-redirect=true您可以通过将参数附加到结果查询字符串来执行重定向。例如
public String submit() {
// ...
return "/pages/index.xhtml?faces-redirect=true";
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2754 次 |
| 最近记录: |