why notification bar does not work?
我为我的应用程序使用了primefaces通知栏。我希望它仅在用户登录并重定向到名为main.xhml的页面时显示
我正在尝试执行此操作,但是我不知道为什么我无法使其显示。
这是一种位于托管Bean中的方法,该方法在单击名为login.xhtml:
的页面上的登录按钮时执行重定向。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | @ManagedBean @RequestScoped public class SecurityController { @EJB private IAuthentificationEJB authentificationEJB; public String logIn() { if (authentificationEJB.saveUserState(email, password)) { // Pass a parameter in ussing the URL.(The notification bar will // read this parameter) return"main.xhtml?faces-redirect=true&login=1"; } else { return null; } } |
这是用户单击以在名为login.xhtml
的页面上登录的按钮。
1 | <h:commandButton value="Login" action="#{securityController.logIn()}"/> |
这是用户登录后到达的页面(main.xhtml):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <ui:composition template="WEB-INF/templates/BasicTemplate.xhtml"> <ui:define name="mainForm"> The main page <!-- Why this dont work? --> <script type="text/javascript"> jQuery(function() { topBar.show() }); <!-- It is possible to change font --> <p:notificationBar id="notbar" position="top" widgetVar="topBar" styleClass="top" rendered="#{param.login == '1'}"> <h:outputText value="Welcome, you are now logged in!" style="color:#FFCC00;font-size:36px;" /> </p:notificationBar> </ui:define> </ui:composition> |
在URL中,我可以看到login = 1,但是当用户到达main.xhtml时,通知栏不会出现。
如何使其显示?
另外,您知道3秒钟后如何使它以淡入淡出的效果消失吗?
在
并使其消失,只需使用setTimeOut()
调用