我使用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