【发布时间】:2011-12-15 08:39:29
【问题描述】:
我在我的 jsf 应用程序中使用 facelets 进行模板化。我想在 ui:composition 标记中有条件地包含一个模板文件。如果用户已登录,则模板必须为“authorized.xhtml”,如果用户未登录,则模板必须为“unauthorized.xhtml”。有没有办法做到这一点?谢谢。
<ui:composition template="/templates/unauthorized.xhtml">
<ui:composition template="/templates/authorized.xhtml">
我正在使用 JSF 1.2。
【问题讨论】:
-
我现在正在从我正在检查用户是否登录的支持 bean 中的方法中检索模板值。如果用户已登录,我返回“/templates/authorized.xhtml”,否则返回“/templates/unauthorized.xhtml”。我无法将其作为答案发布,因为我没有 100 个声誉点。