PrimeFaces ::显示p:Dialog来填写表单字段,而无需重新发布 [英] PrimeFaces :: display p:Dialog to fill-in a form field, without reposting
问题描述
我有一个数据输入表单,其中显示了多个字段(主要是 p:inputText )供用户提供.其中一些是LOV,因此我显示 p:dialog 以允许用户选择正确的值. p:对话框通过 p:inputText 旁边的 p:commandLink 显示.代码的主要部分如下所示:
I have a data-entry form that displays a number of fields (mostly p:inputText) for the user to provide. Some of these are LOVs so I display a p:dialog to allow the user to select the right value. The p:dialog is displayed by means of a p:commandLink next to the p:inputText. Main parts of code shown below:
<h:form id="parentForm">
(...)
<p:inputText value="#{CustomerCEVController.customer.municipality}" id="customerMncName"/>
<p:commandLink type="button" onclick="MunicipalityDlg.show()" styleClass="ui-icon ui-icon-search"/>
(...)
<p:commandButton value="Submit" id="save" actionListener="#{CustomerCEVController.saveButtonListener}" /> (...)
</h:form>
问题是,每当用户单击 p:commandLink 以显示 p:dialog (允许他选择其中一个值)时,外部形式由于 p:commandLink 被放置在 h:form 内,因此要经历其生命周期阶段(还原视图,应用请求值,过程验证等).如何实现此对话框显示功能,同时避免在用户打开的每个对话框中发布 h:form ?
The problem is, whenever the user clicks on the p:commandLink to display the p:dialog (to allow him to select one of the values) the outer form goes through its lifecycle phases (restore view, apply request values, process validations, etc.) since the p:commandLink is placed inside an h:form. How can I implement this dialog-displaying functionality while avoiding posting the h:form with every dialog that the user opens?
推荐答案
只需将"return false"作为最后一个语句添加到onclick事件处理程序即可.它阻止了CommandLink的默认功能(发布表单).
Just add "return false" as the last statement to onclick event handler. It prevents commandLink's default function (posting the form).
这篇关于PrimeFaces ::显示p:Dialog来填写表单字段,而无需重新发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!