【问题标题】:Primefaces <p:blockUI> hidding growl <p:growl> after releasingPrimefaces <p:blockUI> 释放后隐藏咆哮 <p:growl>
【发布时间】:2014-10-17 15:09:36
【问题描述】:

我正在尝试通过单击支持 bean 中的按钮来更新消息,同时在单击按钮后我试图阻止此按钮以避免双击。阻塞成功并出现消息,但在解除阻塞后消息消失。这发生得很快。我希望咆哮中的信息保持更长时间。 我的 .jsf sn-p。

<h:form id="form">
    <p:growl id="messages" />
    <p:blockUI block="button" widgetVar="block"/>
        <p:dataTable var="item" id="table" value="#{bean.lazyModel}"
            lazy="true">
            <p:column>
                <p:commandButton value="#{item.actionBtn}" 
                    update=":form:messages" action="#{bean.action}"
                    oncomplete="filterTableFromPanel();PF('block').hide()"
                    onclick="PF('block').show()">
                </p:commandButton>
            </p:column>
        </p:dataTable> 
</h:form>

像往常一样在 backing bean 中。

public void action(){
   FacesContext.getCurrentInstance().addMessage(null, msg);
}

请原谅我可能的错误,片段已被修剪。

【问题讨论】:

    标签: jsf jsf-2 primefaces blockui


    【解决方案1】:

    您可以选择设置stickylife

    • sticky 保持growl 可见,直到用户手动关闭咆哮组件

    • life 为组件设置超时时间。此值将确定消息可见的时间,然后在 life 过去后消失。以毫秒为单位设置此值life="1200"(默认为6000

    【讨论】:

    • 谢谢,但我尝试过这种方式,结果相同。此外,我尝试在这个 primefaces.org/showcase/ui/misc/blockUI.xhtml 示例(基本部分)中进行所有操作,其中 blockUI 在咆哮时可以正常工作,但对我来说它不起作用。
    • 你具体试过哪个@SergeyVasnev?
    • 正如我所说,我已经尝试根据我的案例调整 Basic 部分中的示例 - 教程页面上的第一个示例描述了与我的案例类似的案例,但是对于我这不起作用。
    • 网站上的所有例子都没有使用sticky of life属性。你是说你两个都用了,都没有用? @SergeyVasnev
    • 我知道那些网站上的示例都没有使用这些属性。我已将此添加为附加信息。正如我所说,我已经使用了这种“生命”和“粘性”属性。它没有帮助。
    【解决方案2】:

    我已经使用 p:remoteCommand 解决了我的问题。

    <h:form id="form">
        <p:growl id="messages" />
        <p:blockUI block="button" widgetVar="block"/>
        <p:remoteCommand name="addMessage"
    			action="#{bean.addMessage}"
    			update=":form:messages" />
            <p:dataTable var="item" id="table" value="#{bean.lazyModel}"
                lazy="true">
                <p:column>
                    <p:commandButton value="#{item.actionBtn}" 
                        update=":form:messages" action="#{bean.action}"
                        oncomplete="filterTableFromPanel();PF('block').hide(); addMessage()"
                        onclick="PF('block').show()">
                    </p:commandButton>
                </p:column>
            </p:dataTable> 
    </h:form>

    在支持 bean 中,我添加了如下内容:

    public void addMessage(){
       FacesContext.getCurrentInstance().addMessage(null, "msg");
    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多