Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么通知栏不工作?_Java_Javascript_Jsf_Jsf 2_Primefaces - Fatal编程技术网

Java 为什么通知栏不工作?

Java 为什么通知栏不工作?,java,javascript,jsf,jsf-2,primefaces,Java,Javascript,Jsf,Jsf 2,Primefaces,我在我的应用程序中使用。我希望它在用户登录并被重定向到名为main.xhtml的页面时出现 我试着去做,但我不知道为什么我不能让它出现 这是一个位于托管bean中的方法,在单击名为login.xhtml的页面上的登录按钮时执行重定向: @ManagedBean @RequestScoped public class SecurityController { @EJB private IAuthentificationEJB authentificationEJB; p

我在我的应用程序中使用。我希望它在用户登录并被重定向到名为main.xhtml的页面时出现 我试着去做,但我不知道为什么我不能让它出现

这是一个位于托管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):


主页
jQuery(函数(){
topBar.show()
});
在URL中,我可以看到login=1,但当用户到达main.xhtml时,通知栏不会出现

我怎样才能让它出现?
另外,您知道如何使其在3秒钟后消失并具有淡入淡出效果吗?

请在
之后使用脚本,因为如果您在通知栏之前编写,则加载时将找不到DOM


要使其消失,只需调用
topBar.hide()
with

在FF中的错误控制台上是否可以看到与javascript相关的错误消息?eclipse中的控制台中完全没有错误。浏览器控制台中也没有错误。不是在服务器控制台中,我说的是你能用
rendered=“#{param.login==''1'}
更改条件吗?注意,在
我尝试
topBar.hide().delay(2000)之后添加了一个单引号,涵盖了一个推送脚本
但是消失得太快了。为什么它不等待2秒?很抱歉,忘记了延迟工具使用这个
设置超时(“topBar.hide()”,3000);
<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>