gpt4 book ai didi

jsf - Primefaces 在重置表单输入时处理属性

转载 作者:行者123 更新时间:2023-12-01 02:19:22 25 4
gpt4 key购买 nike

我在模态对话框中有一个表单,在关闭(实际上隐藏)一个表单后,我想重置用户可能已更改的所有输入。我想如下:

<p:dialog widgetVar="myDialog">
<h:form id="formId">
<!-- ... -->
<p:commandButton value="Cancel" onclick="myDialog.hide();"
update="formId">
<p:resetInput target="formId" />
</p:commandButton>
</h:form>
</p:dialog>

但结果并不是我所期望的。经过一段时间的搜索,我找到了一个解决方案,即添加 process="@this"归因于 <p:commandButton> .我的问题是为什么有必要?在需要这个过程的背景下真正发生了什么。我根本没有真正了解过程属性的概念。

最佳答案

我已经对对话框做了一些工作,并且我使表单为空的方法是,当单击按钮打开对话框时,我在支持 bean 中运行了一个方法,该方法清除了我的 pojo,因此我的表单具有空值。

在你的情况下,它可能是这样的:

<h:form id="form-button">
<p:commandButton id="AddButton" value="open dialog box"
update=":form" action="#{myBean.myMethodToSetPojoNull}" immediate="true"
oncomplete="PF('myDialog').show()" />
</h:form>

单击此按钮时,调用的方法会将所有字段设置为 null,您的对话框将为空。回到你为什么的问题 process=@this有必要更好地解释答案在这里

What is the function of @this exactly?

关于jsf - Primefaces 在重置表单输入时处理属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21722145/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com