Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.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
Jsf 2 jsf2 primefaces通知栏_Jsf 2_Primefaces - Fatal编程技术网

Jsf 2 jsf2 primefaces通知栏

Jsf 2 jsf2 primefaces通知栏,jsf-2,primefaces,Jsf 2,Primefaces,我希望在我的jsf页面中有通知栏。当我使用这个示例代码时,它是有效的 <p:notificationBar position="top" effect="slide" styleClass="top" widgetVar="notifBar"> <h:outputText value="Hi ..." style="font-size:36px;" /> </p:notificationBar> <p:comma

我希望在我的jsf页面中有通知栏。当我使用这个示例代码时,它是有效的

    <p:notificationBar position="top" effect="slide" styleClass="top" widgetVar="notifBar">
        <h:outputText value="Hi ..." style="font-size:36px;" />
    </p:notificationBar>

    <p:commandButton value="Show2" onclick="PF('notifBar').show();" type="button"/>

但是当我使用这个代码时,它不起作用

    <p:commandButton value="Show1" onclick="notifBar.show()" type="button"/>

这个PF为什么和做什么? 我的最后一种方法是使用自动隐藏通知面板,但当我使用这样的代码时

    <p:commandButton value="Show2" onclick="PF('notifBar').show();setTimeout(PF('notifBar').hide, 3000)" type="button"/>

它显示了这个错误:

未捕获的TypeError:无法读取未定义的属性“effect” PrimeFaces.widget.NotificationBar.PrimeFaces.widget.BaseWidget.extend.hide

根据这个准则

    <p:commandButton value="Show2" onclick="PF('notifBar').show();setTimeout(notifBar.hide, 3000)" type="button"/>

它表明

未捕获引用错误:未定义notifBaris

谁能帮我一下吗?


<p:commandButton value="Show1" onclick="notifBar.show()" type="button"/>
notifBar
等于
widgetVar=“notifBar”
,这意味着它是客户端组件,而您的服务器不知道
notifBar
,要显示它,您必须像这样做:
PF('client\u Wiget\u War')。show

By Doc:'widgetVar是客户端变量的名称'

隐藏通知栏

未捕获引用错误:未定义notifBar

这是因为
notifBar
是客户端组件 目前,我正在尝试复制您的
setTimeout
场景,但失败了