Jsf 2 jsf2 primefaces通知栏
我希望在我的jsf页面中有通知栏。当我使用这个示例代码时,它是有效的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
<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
场景,但失败了