ignoreValidationFailed在p:dataTable中不起作用 [英] ignoreValidationFailed doesn´t work inside p:dataTable
问题描述
我正在datatable内部使用actionListener ajax调用,并尝试执行以下操作:
I am using actionListener ajax call inside datatable and trying to do the following :
- 跳过验证
- 使用插入的值更新模型
我知道BalusC的omnifaces实用程序库可以使用o:ignoreValidationFailed做到这一点 但这使我无法在primefaces数据表中工作.
I knew that omnifaces utility liberary by BalusC can do this using o:ignoreValidationFailed But it failed with me to work inside primefaces datatable.
我还发现在另一篇帖子此处 我不知道它是否是一个错误. 这是我的代码示例
Also I found that it failed to work inside ui:repeat in another post here I dont know if its a bug or not. here is my code example
<o:form id ="trans_desc_form">
<p:outputPanel id="stkdetailsid">
<p:dataTable id="transactiondetailsid" value="#{stockTransactionsBean.stkTransHeader.stkTransDetailsList}"
var="stkTransDet" rowIndexVar="rowIndex">
<p:column>
<f:facet name="header">
<h:outputText value="Item Code" />
</f:facet>
<p:autoComplete id="dd" required="true"
value="#{stkTransDet.item}" var="i" itemLabel="#{i.itemno} #{i.itemnamee}"
itemValue="#{i}" converter="itemsConverter"
completeMethod="#{stockTransactionsBean.completeItems}"/>
</p:column>
<p:column>
<p:commandButton value="-" update="@form" process="@form"
actionListener="#{stockTransactionsBean.removeRow(rowIndex)}">
<o:ignoreValidationFailed />
</p:commandButton>
</p:column>
</p:dataTable>
</p:outputPanel>
</o:form>
作为一种解决方法,我添加了
As a workaround, I added
1-将条件添加到必填字段,以了解ajax是否来自提交"按钮 到autoComplete组件,其中trans_desc_form是整个表单ID,savetransid是提交按钮的保存ID
1- add a condition to the required field to know if the ajax come from submit button or not to the autoComplete component where the trans_desc_form is thte entire form id and savetransid is the submit button save id
required="#{!empty param['trans_desc_form:savetransid']}"/>
2-我从JPA实体中删除了@NotNull,从而强制了验证
2- I removed @NotNull from my JPA entity which force the validation
@JoinColumn(name = "ITEMNO", referencedColumnName = "ITEMNO")
@ManyToOne(optional = false, fetch = FetchType.LAZY)
//@NotNull
private Item item;
推荐答案
要跳过验证,可以在p:commandButton
这篇关于ignoreValidationFailed在p:dataTable中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!