隨筆-348  評論-598  文章-0  trackbacks-0
          //Example 1: This is wrong:
          public class ViewHeadlineAction implements Action, ModelDriven {
          Headline headline 
          = new Headline();
          public Object getModel() {
          return this.headline ;
          }

          // 
          public String execute() {
          headline 
          = headlineFactory.findLatest();
          return SUCCESS;
          }

          }

          b
          //Example 2: This is correct:
          public class ViewHeadlineAction implements Action, ModelDriven {
          Headline headline 
          = new Headline();
          public Object getModel() {
          return this.headline ;
          }

          // 
          public String execute() {
          headlineFactory.updateToLatest(headline);
          return SUCCESS;
          }

          }

          Example 1 attempts to change the instance that getModel() returns. However,
          because getModel() is called before execute() and before the object is pushed
          onto the value stack, the reference that WebWork uses is the original instance, created
          by new Headline(), not the instance loaded from the HeadlineFactory. The
          second example resolves this issue by updating the existing instance rather than
          having headline point to a new instance.

          ---------------------------------------------------------
          專注移動開發

          Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
          posted on 2007-04-11 18:30 TiGERTiAN 閱讀(311) 評論(0)  編輯  收藏 所屬分類: WebWork
          主站蜘蛛池模板: 龙游县| 桦川县| 拜城县| 青田县| 吉木萨尔县| 莫力| 江津市| 栾城县| 光山县| 中山市| 壤塘县| 长垣县| 天台县| 襄汾县| 林甸县| 内丘县| 尼勒克县| 大姚县| 上林县| 常熟市| 盐山县| 郁南县| 高邮市| 改则县| 南漳县| 大兴区| 虞城县| 辽阳市| 湘阴县| 台中市| 鄱阳县| 子长县| 大连市| 光山县| 龙山县| 介休市| 太原市| 花莲县| 河曲县| 香港| 崇阳县|