p:resetInput重新打开时不会重置p:dialog [英] p:resetInput does not reset the p:dialog when it is reopened

查看:76
本文介绍了p:resetInput重新打开时不会重置p:dialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我正在编写的一些HTML,允许使用对话框添加类别:

Here is some html I am writing to allow categories to be added using a dialog:

<p:dialog id="newCategoryDlg" header="Add New Category" widgetVar="newCategoryDialog" resizable="false">

    <h:form id="newCategoryForm">
        <p:panelGrid id="displayNewCategory" columns="2" cellpadding="4" style="margin:0 auto;">

            <h:outputText value="Category Name :"></h:outputText>
            <p:inputText value="#{categoryController.newCategory.name}"
                         required="true" requiredMessage="Please Enter a Category ID!" />


            <f:facet name="footer">
                <p:commandButton value="Submit" update=":form:categoryTable"
                                 oncomplete="newCategoryDialog.hide();"
                                 actionListener="#{categoryController.addCategory}">
                    <p:resetInput target="displayNewCategory" />
                </p:commandButton>
                <p:commandButton type="reset" value="Reset"></p:commandButton>
            </f:facet>
        </p:panelGrid>




    </h:form>
</p:dialog>

现在,无论出于何种原因,无论我使用哪个小部件或标识符,"似乎都不起作用.我只想让旧的输入条目在提交后消失.我在做什么错了?

Now, for whatever reason, "" just doesn't seem to work no matter which widget or identifier I use. All I want is for old input entries to disappear after they have been submitted. What am I doing wrong?

推荐答案

您误解了< p:resetInput> 的目的.基本上已经在这里解决/解释了这种误解:

You misunderstood the purpose of <p:resetInput>. This misunderstanding is essentially already answered/explained here: Why does p:resetInput require properties of a managed bean to be set to null first after the form is submitted?

关于您需要在打开对话框之前更新对话框内容的具体功能要求,只需在打开对话框的命令按钮中进行相应操作即可:

As to your concrete functional requirement of the need to update the dialog's content before opening, just do exactly that in the command button which opens the dialog:

<h:form>
    <p:commandButton value="Open dialog" action="#{dialogBean.init}" 
        process="@this" update=":dialog" oncomplete="w_dialog.open()" />
</h:form>

...

<p:dialog id="dialog" widgetVar="w_dialog" ...>

请注意,当对话框包含需要验证的字段时,< p:resetInput> 将非常适用于更新和打开对话框以清除无效字段的按钮状态.

Note that when the dialog contains fields which needs to be validated, then the <p:resetInput> would be very applicable in the button who's updating and opening the dialog in order to clear out invalid state.

这篇关于p:resetInput重新打开时不会重置p:dialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆