我使用primefaces notification Bar为我的应用程序。我希望它只出现在用户登录并被重定向到一个名为main.xhml的页面时 我正在尝试这样做,但我不知道为什么我不能让它出现。为什么通知栏不起作用?
这是坐落在一个托管Bean,它确实在点击页面中的登录按钮叫login.xhtml当重定向的方法:
@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
<h:commandButton value="Login" action="#{securityController.logIn()}"/>
这里页面中,用户到达时(main.xhtml)获得loged页:
<ui:composition template="WEB-INF/templates/BasicTemplate.xhtml">
<ui:define name="mainForm">
<h2>The main page</h2>
<!-- Why this dont work? -->
<script type="text/javascript">
jQuery(function() {
topBar.show()
});
</script>
<!-- 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秒后的淡出效果?
你可以看到相关的JavaScript在FF您的错误控制台上的错误信息? – 2011-04-22 09:28:22
eclipse中的控制台没有错误。而不是在浏览器控制台中的错误。 – sfrj 2011-04-22 09:40:44
不在服务器的控制台,我在说[浏览器的控制台] – 2011-04-22 09:42:09