【问题标题】:jsf2 primefaces notification barjsf2 primefaces 通知栏
【发布时间】:2015-04-25 19:57:33
【问题描述】:

我想在我的 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"/>

它显示了这个错误:

未捕获的类型错误:无法读取未定义的属性“效果” PrimeFaces.widget.NotificationBar.PrimeFaces.widget.BaseWidget.extend.hide

通过这段代码

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

它显示

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

谁能帮帮我..

【问题讨论】:

    标签: jsf-2 primefaces


    【解决方案1】:
    <p:commandButton value="Show1" onclick="notifBar.show()" type="button"/>
    

    notifBar 等于widgetVar="notifBar",这意味着它是一个客户端组件,而您的服务器不知道notifbar,要显示它,您必须这样做:PF('client_Wiget_War').show;

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

    WRT 隐藏通知栏

    未捕获的 ReferenceError:notifBar 未定义

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-21
      • 1970-01-01
      • 2011-08-25
      • 2021-12-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多