我的Richfaces应用程序中有一个屏幕,该屏幕使用数据表和数据滚动器,并进行验证以确保填充数据。 (示例为模拟问题,完整示例参见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>
当用户按下“提交”按钮(以保存数据)时,以及当用户使用分页转到另一个页面时,都应该进行数据验证。
在将一个字段留空后单击“提交”按钮时,行为是正常的:它显示一个空字段,并带有“此为必填项”标记。
但是,当改为移动到另一个页面(例如,单击“ 2”页面按钮)时,验证会正确进行,但是旧值会重新输入到屏幕中,从而表明该值应填写但显示它填充了一个值。
任何人都不知道此问题可能是什么原因,以及如何解决?这是RichFaces中的错误,还是我忽略了某些内容?
答案 0 :(得分:0)
我通过反复试验找到了解决方案:
如果我将数据滚动条更改为使用render =“ @ region”,则屏幕将正确呈现。
<rich:dataScroller for="articleTable" renderIfSinglePage="false" boundaryControls="show" fastControls="hide" execute="@form" render="articleTable"
stepControls="show" style="float:right;" />