我想在我的jsf頁面中有通知欄。當我使用此示例代碼它的工作原理jsf2 primefaces通知欄
<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"/>
代碼它顯示了這個錯誤:
Uncaught TypeError: Cannot read property 'effect' of undefined PrimeFaces.widget.NotificationBar.PrimeFaces.widget.BaseWidget.extend.hide
,並通過這個代碼
<p:commandButton value="Show2" onclick="PF('notifBar').show();setTimeout(notifBar.hide, 3000)" type="button"/>
它顯示
Uncaught ReferenceError: notifBaris not defined
誰能幫我請..