There are a commandlink or command button at first page,after submitted some values but others needed to be validated is inputted null,with this case if I wantto goto next page to do sth like create subproperites list for current page,there will happenes situtaion as following: 1.if set immediated=true, it will goto next page welll witout any vlaidation error as this setting will ignore the before 4 phases of lifecyle of JSF.Just for this, it willnot perform the phase of "Updated Model Values", so after did some at second page,the submitted values in first page will be missing. 2.the optimistic case, that means set immediated =false, it will perform all phases of lifecle of JSF, that is to say if user can not submit all,it validation can not be passed. |
最后发现使用ajax 可以解决着问题,比较优雅地。
<a4j:region id="reg_costCentreCode">
<h:inputText value="#{costCentrePage.suEstCostCentre.costCentreCd}" id="CostCentreCode" size="16">
<vtv:commonsValidator arg="CostCentreCode" required="true" maxlength="15" mask="^[0-9a-zA-Z]*$"/>
<a4j:support ajaxSingle="true" event="onchange" reRender="a4j_costCentreCode"/>
</h:inputText>
</a4j:region>
<t:div id="a4j_costCentreCode">
<t:message for="CostCentreCode" styleClass="txtLabelError" />
</t:div>
使用ajax的异步处理,可以很好的解决这样问题,当我从下一个页面回来的时候,值还在,除非之前的验证没有通过----验证通过又怎么可以goto到下个页面呢。所以,我说还是不错的。。