简体   繁体   English

数据表中的Richfaces 4错误,为空时使用datascroller验证

[英]Richfaces 4 bug in datatable with datascroller validation when empty

I have a screen in my Richfaces application which uses a datatable and datascroller, with validation to ensure that data is filled. 我的Richfaces应用程序中有一个屏幕,该屏幕使用数据表和数据滚动器,并进行验证以确保填充数据。 ( example to simulate the problem, full example can be found here (用于模拟问题的示例,可以在此处找到完整的示例

 <h:form id="articleForm" > <h:panelGroup layout="block"> <rich:messages globalOnly="true" /> <rich:dataTable value="#{productModifyBean.articles}" var="article" id="articleTable" rows="15" > <rich:column headerClass="headerOverflow artNrColumn"> <f:facet name="header"> <h:outputText value="articleNumber" /> </f:facet> <h:outputText value="#{article.articleNumber}"/> </rich:column> <rich:column headerClass="headerOverflow shortNameColumn"> <f:facet name="header"> <h:outputText value="Name" /> </f:facet> <h:outputText value="#{article.shortName}" /> </rich:column> <rich:column headerClass="headerOverflow quantityColumn" > <f:facet name="header"> <h:outputText value="Quantity" /> </f:facet> <h:inputText value="#{article.quantity}" required="true" requiredMessage="This is required" converterMessage="Error conversion" id="modifyArticleFormatQuantity" > </h:inputText> <rich:message for="modifyArticleFormatQuantity" errorClass="errorColorRed" /> </rich:column> </rich:dataTable> <rich:dataScroller for="articleTable" renderIfSinglePage="false" boundaryControls="show" fastControls="hide" execute="@form" render="articleTable" stepControls="show" style="float:right;" /> </h:panelGroup> <br style="clear: both" /> <br style="clear: both" /> <div align="right" style="clear: both"> <a4j:commandButton value="#{msgs['button.modify'] }" styleClass="submitButton" render="#{facesContext.validationFailed ? '@none' : 'articleForm'}" actionListener="#{productModifyBean.modifyProduct}"> </a4j:commandButton> </div> </h:form> 

Data validation should happen when the user presses the submit button ( to save the data) , and when the user using the pagination to go to a different page. 当用户按下“提交”按钮(以保存数据)时,以及当用户使用分页转到另一个页面时,都应进行数据验证。

When clicking the submit button after leaving one field empty, the behaviour is normal : it shows an empty field with the remark 'this is required' 在将一个字段留空后单击提交按钮时,行为是正常的:它显示一个空字段,并带有备注“此为必填项”

在此处输入图片说明

However, when instead moving to a different page ( for example clicking on the '2' page button ) , validation happens correctly, but the old value is put back into the screen, thus stating that the value should be filled but showing it filled in with a value. 但是,当改为移动到另一个页面(例如,单击“ 2”页面按钮)时,验证会正确进行,但是旧值将重新输入到屏幕中,从而表明该值应被填充但显示为已填充一个值。

在此处输入图片说明

Anyone have any idea what the reason for this problem could be, and how to resolve it ? 任何人都知道导致此问题的原因是什么,以及如何解决它? Is this a bug in RichFaces, or am I overlooking something ? 这是RichFaces中的错误,还是我忽略了某些内容?

I found the solution by trial and error : 我通过反复试验找到了解决方案:

If I change the datascroller to use render="@region" , the screen is correctly rendered. 如果我将datascroller更改为使用render =“ @ region”,则屏幕将正确呈现。

 <rich:dataScroller for="articleTable" renderIfSinglePage="false" boundaryControls="show" fastControls="hide" execute="@form" render="articleTable"
                    stepControls="show" style="float:right;" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM