Fuv*_*Fuv 4 jsf primefaces jsf-2
我在模态对话框中有一个表单,在关闭(实际上隐藏)一个表单后,我想重置用户可能已更改的所有输入。我想如下:
<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>
Run Code Online (Sandbox Code Playgroud)
但结果并不是我所期望的。经过一段时间的搜索,我找到了一个解决方案,将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>
Run Code Online (Sandbox Code Playgroud)
单击此按钮时,调用的方法会将所有字段设置为 null,您的对话框将为空。回到你为什么process=@this需要更好解释的答案的问题在这里
| 归档时间: |
|
| 查看次数: |
2542 次 |
| 最近记录: |