具有登录组件的JSF标头? [英] JSF Header with Login Component?
问题描述
我对JSF以及其中的许多相关技术还很陌生。
I'm pretty new to JSF and the many many related technologies out there.
我正在尝试制作一个网站,该网站的标头包含徽标,导航链接和登录框,以便除非用户登录即可将该标题轻松包含在网站的所有页面中,否则将出现一个不同的标题。与 livejournal 类似。
I'm trying to make a website that has a header which includes a logo, navigation links, and a login box, such that this header can easily be included in all of the site's pages unless the user logs in, in which case a different header will appear. Something similar to livejournal.
我研究了一些解决方案,例如创建自定义JSF组件以处理登录并将其与JSP片段和/或Facelets结合。但是经过大量Google搜索之后,我还没有真正找到尝试制作自定义登录组件的人,而且关于创建这样的标头的信息很少。那么,这真的是解决我的问题的正确方法吗?有更好的解决方案吗?
I've looked into a few solutions like creating a custom JSF component to handle login and combining that with JSP fragments and/or Facelets. But after a lot of Google searching, I haven't really found anyone who has tried to make a custom login component and information about creating a header like this is sparse. So is this really the right way to go about solving my problem? Is there a better solution?
谢谢。
推荐答案
我肯定会使用Facelets,因为基本上可以让您在每个页面上包含相同的标题。
I would definitely use Facelets as that will basically let you include the same header on each page.
就自定义登录组件而言-这取决于您的处理方式您的登录名。如果您使用的是JAAS或Spring Security,则需要与它们集成(可以做到)。
In terms of a custom login component - it depends on how you're handling your login. If you're using JAAS or Spring Security you will need to integrate with them (it can be done).
不过,登录标题并不难。例如,您可以执行以下操作:
However a login header needn't be difficult. For example, you could just do something like:
<h:form id="loginForm" rendered="#{! loginBean.loggedIn}">
Username: <h:inputText id="username" value="#{loginBean.username}" />
Password: <h:inputPassword id="password" value="#{loginBean.password}" />
<h:commandButton value="Login" action="#{loginBean.login}" />
</h:form>
<h:outputText rendered="#{loginBean.loggedIn}" value="You are logged in as #{loginBean.username}" />
这篇关于具有登录组件的JSF标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!