posts - 0,  comments - 0,  trackbacks - 0

          1.Let the life cycle proceed normally.

          2.Call FacesContext.renderResponse() to skip the rest of the life cycle up to Render Response.

          3.Call FacesContext.responseComplete() to skip the rest of the life cycle entirely.

          See "Immediate Components" on page 287 for an example of using FacesContext.renderResponse().

            private static final String US = "United States";
            
            
          public void countryChanged(ValueChangeEvent event) {
               FacesContext context 
          = FacesContext.getCurrentInstance();

               
          if (US.equals((String) event.getNewValue()))
                  context.getViewRoot().setLocale(Locale.US);
               
          else
                  context.getViewRoot().setLocale(Locale.CANADA);

               context.renderResponse();
            }

          The call to renderResponse() skips the rest of the life cycle—including validation of the rest of the input components in the form—up to Render Response. Thus, the other validations are skipped and the response is rendered normally (in this case, the current page is redisplayed).

          To summarize, you can skip validation when a value change event fires by doing the following:

          1. Adding an immediate attribute to your input tag

          2. Calling FacesContext.renderResponse() at the end of your listener


                 

           上文引用:《core JavaServer™ Faces, Second Edition》
          posted on 2007-12-11 19:57 *一凡* 閱讀(161) 評論(0)  編輯  收藏 所屬分類: JSF
          主站蜘蛛池模板: 和平县| 六盘水市| 西青区| 建始县| 永丰县| 河北区| 兰考县| 锦屏县| 新竹市| 巴林右旗| 安乡县| 会理县| 玉龙| 中阳县| 遂宁市| 连平县| 松潘县| 会泽县| 得荣县| 邹平县| 邵东县| 蓬莱市| 塘沽区| 濮阳县| 砀山县| 玛多县| 西畴县| 正蓝旗| 雷州市| 吴江市| 新闻| 孝感市| 宜良县| 兰溪市| 三穗县| 治多县| 报价| 乌恰县| 甘孜| 武强县| 平定县|