隨筆-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
          主站蜘蛛池模板: 上饶县| 西畴县| 睢宁县| 白玉县| 游戏| 绥江县| 霍山县| 广宁县| 佳木斯市| 河源市| 曲水县| 宁国市| 大渡口区| 永济市| 汝南县| 石阡县| 内江市| 宁波市| 临泉县| 富阳市| 宣武区| 平凉市| 兴业县| 通城县| 商河县| 台南县| 祥云县| 拜泉县| 南投市| 万年县| 察隅县| 来凤县| 甘泉县| 右玉县| 普安县| 尖扎县| 石家庄市| 洪江市| 广南县| 理塘县| 和平县|