JSF应用时候发现的一个问题。

 
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到下个页面呢。所以,我说还是不错的。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值