richfaces popupPanel:命令按钮需要单击两次

发布于 2025-01-02 07:41:25 字数 1381 浏览 3 评论 0原文

我有一个弹出窗口,上面有一个表单和一个命令按钮。当我单击命令按钮时,我想提交表单并调用操作。

问题是,如果我将命令按钮放在表单中,我必须单击它两次才能调用操作,如果我将它放在表单之外,它不会提交表单。

这是我的代码:

<rich:popupPanel id="popup" modal="true" minWidth="600" minHeight="300"
    resizeable="false">
    <f:facet name="header">
        <h:outputText value="Edit" />
    </f:facet>
    <f:facet name="controls">
        <h:outputLink value="#" id="x"
            onclick="#{rich:component('popup')}.hide(); return false;">X</h:outputLink>
    </f:facet>
    <h:form id="dataForm">

        <table id="table">
            <tr>
                <td><h:outputText value="Details:" /></td>
                <td><h:inputTextarea id="details"
                        value="#{errorItemBean.workItem.details}" /></td>
            </tr>               
        </table>

        <a4j:commandButton id="submitButton" value="Ok"
                action="#{errorItemBean.create}" reRender="errorForm"
                oncomplete="#{rich:component('popup')}.hide()">
            </a4j:commandButton>

        <h:commandButton id="cancelButton" value="Cancel">
            <rich:componentControl target="popup" operation="hide" />
        </h:commandButton>
    </h:form>
</rich:popupPanel>

I have a popup window with a form and a commandButton on it. When I click on the commandButton, I would like to submit the form and call an action.

The problem is that if I put the commandButton in the form, I have to click on it twice to call the action, and if I put it outside the form, it doesn't submit the form.

Here is my code:

<rich:popupPanel id="popup" modal="true" minWidth="600" minHeight="300"
    resizeable="false">
    <f:facet name="header">
        <h:outputText value="Edit" />
    </f:facet>
    <f:facet name="controls">
        <h:outputLink value="#" id="x"
            onclick="#{rich:component('popup')}.hide(); return false;">X</h:outputLink>
    </f:facet>
    <h:form id="dataForm">

        <table id="table">
            <tr>
                <td><h:outputText value="Details:" /></td>
                <td><h:inputTextarea id="details"
                        value="#{errorItemBean.workItem.details}" /></td>
            </tr>               
        </table>

        <a4j:commandButton id="submitButton" value="Ok"
                action="#{errorItemBean.create}" reRender="errorForm"
                oncomplete="#{rich:component('popup')}.hide()">
            </a4j:commandButton>

        <h:commandButton id="cancelButton" value="Cancel">
            <rich:componentControl target="popup" operation="hide" />
        </h:commandButton>
    </h:form>
</rich:popupPanel>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怪异←思 2025-01-09 07:41:25

如果您在打开弹出窗口之前使用了 reRender=":popup",则可能会发生这种情况。您需要通过 reRender=":dataForm" 重新渲染弹出窗口的表单。

另请参阅:

That can happen if you have used reRender=":popup" before opening the popup. You need to re-render the popup's form instead by reRender=":dataForm".

See also:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文