【问题标题】:oncomplete of p:commandButton not firing within ui:compositionp:commandButton 的 oncomplete 未在 ui:composition 内触发
【发布时间】:2015-04-16 19:00:14
【问题描述】:

以下代码出现在 ui:composition 页面并使用模板,模板使用 ui:insert 插入此页面。

        <p:commandButton id="basic" value="Contact #{viewProfileView.profile.credentials.username}" onclick="PF('dlg1').show();" type="button" />

    <h:form id="createMail">
        <p:dialog id="createMailDialog" header="Contact #{viewProfileView.profile.credentials.username}" widgetVar="dlg1" modal="true" draggable="false">
            <p:growl id="growl"/>

            <p:inputTextarea value="#{viewProfileView.emailBody}"
                             rows="5" cols="80" maxlength="399"
                             counter="charsLeft" 
                             counterTemplate=" {0} chars remaining."
                             autoResize="false" />
            <h:outputText id="charsLeft" />

            <p:commandButton id="sendMailButton" value="Send"
                             action="#{viewProfileView.sendMail}"
                             update="growl"
                             oncomplete="PF('dlg1').hide();"/>
        </p:dialog>
    </h:form>

我正在使用最新的 JSF 和 Primefaces 5.1。

除了“sendMailButton”命令按钮的 oncomplete 未能被调用以关闭对话框外,一切正常。我知道这段代码可以工作,因为我将它放在自己的页面中并看到它工作,它只是不想作为带有模板的 ui:composition 的一部分工作。

非常感谢您的帮助,因为我一直在寻找没有运气的答案。

更新:如果我将 'oncomplete' 更改为 'onsuccess' 它可以工作,但只有一次,但这并不能解决我的问题。

非常感谢。

【问题讨论】:

  • 重申一下,上面的代码在它自己的 jsp 中运行良好,但一旦包裹在 ui:composition 和 ui:define 中,oncomplete 和/或更新不会触发。这是兼容性问题吗?

标签: ajax jsf jsf-2 primefaces commandbutton


【解决方案1】:

看来是模板引起了问题。现在工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-24
    • 2012-01-06
    • 1970-01-01
    相关资源
    最近更新 更多