【问题标题】:rich:calendar update backing bean after component edit丰富:组件编辑后的日历更新支持 bean
【发布时间】:2013-04-13 05:41:51
【问题描述】:

我在数据表中有一个丰富的日历组件:

 <rich:column id="last_#{row.index}" >
   <rich:calendar id="lcal_#{row.index}"
     value="#{_obj.list[row.index].lastTaught}">
     <a4j:support event="onchanged"
       action="#{_obj.list[row.index].setBooleanDateHasBeenChanged}"
       ajaxSingle="true" reRender="last_#{row.index}" /> 
   </rich:calendar>
 </rich:column>

当用户更改日期时,我需要将字段设置为 true(我需要知道稍后为 db update 更改了哪些行,我想一次更新一堆行):

 /**
 * when someone changes the last taught field, set has been edited to true
 */
public void resetHasBeenEdited(){
    this.hasBeenEdited = true;
}

当我更改调用 setBooleanDateHasBeenChanged 方法的日期并在支持 bean 中更新 _obj.list 时,但是当我在重新渲染后检查 _obj 时,hasBeenEdited 字段不会反映更改。

我尝试使用 valueChangeListener(更改方法签名以匹配):

 <rich:column id="last_#{row.index}" >
   <rich:calendar id="lcal_#{row.index}"
     value="#{_obj.list[row.index].lastTaught}"
         valueChangeListener="#{_obj.list[row.index].setBooleanDateHasBeenChanged}">
     <a4j:support event="onchanged"
       ajaxSingle="true" reRender="last_#{row.index}" /> 
   </rich:calendar>
 </rich:column>

但是 setBooleanDateHasBeenChanged 甚至没有运行。 如何获得更新支持 bean 的操作并在重新呈现的 JSF 模型中反映该更改? 我正在使用 JSF1.2、RF3.3 和 Seam2.2。

【问题讨论】:

  • valueChangeListener 方法必须遵循与简单的setXXX 方法不同的签名,类似于public void valueChangeMethod(ValueChangeEvent e){ ... }。不确定此更改是否会满足您的要求。顺便说一句,不要编辑setXXX方法,使用其他方法。

标签: jsf richfaces seam


【解决方案1】:

我尝试了一堆不同的配置,但最终成功的是摆脱了 ajaxSingle 和 reRender:

 <rich:column id="last_#{status.index}"     
      <rich:calendar value="#{_obj.list[row.index].lastTaught}" >
      <a4j:support event="onchange"
         actionListener="#{_obj.list[row.index].resetTaughtHasBeenEdited()}"/>
    </rich:calendar>
 </rich:column>

reRender 操作只会将显示的值重置为之前的设置,而 ajaxSingle 不会更新模型。

【讨论】:

    猜你喜欢
    • 2011-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-20
    • 1970-01-01
    • 1970-01-01
    • 2012-03-29
    • 1970-01-01
    相关资源
    最近更新 更多