開花流水

          空山無人,水流花開。

          BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
            79 Posts :: 42 Stories :: 160 Comments :: 0 Trackbacks
          1.轉(zhuǎn)換時間時,必須加上時區(qū)GMT+8,不然相差一天。
          <f:convertDateTime  timeZone="GMT+8" dateStyle="long" type="date"/>
           
          2.<h:outputText value="#{productBean.view}"/>當(dāng)view為空時,不顯示。
           
          3. 
          actionListener在執(zhí)行了action之后再執(zhí)行。
           
          可以沒有action,而只有actionListener。
           
          action可以設(shè)置成一個方法,也可以設(shè)置為一個導(dǎo)航用例的<from-outcome>
          多個頁面如果使用了同一個request級的backingBean,可能導(dǎo)致一些莫名其妙的問題。如:不能執(zhí)行指定的Action.
           
          4.對于向managed-bean的屬性注入request參數(shù)時,其<managed-bean-scope>必須為request,<property-class>不要為值類型(如果是值類型,當(dāng)指定的request參數(shù)為空時, 
          http://www.kpwang.com/注入時會出錯,因為一個空對象如Integer null不能自動轉(zhuǎn)換為一個值類型如int的0)。如下所示:
          <managed-bean>
             <managed-bean-name>productBean</managed-bean-name>
             <managed-bean-class>demo.view.ProductBean</managed-bean-class>
             <managed-bean-scope>request</managed-bean-scope>
             <managed-property>
              <property-name>id</property-name>
              <property-class>java.lang.Integer</property-class>
              <value>#{param.id}</value>
             </managed-property>
             <managed-property>
              <property-name>view</property-name>
              <property-class>java.lang.Boolean</property-class>
              <value>#{param.view}</value>
             </managed-property>
            </managed-bean>
           
          5.對于以下查找是按部件id查找的,不是按參數(shù)名稱查找的。
          UIParameter uip =(UIParameter)event.getComponent().findComponent("productId");
          //event是actionListener中的參數(shù)ActionEvent類型。
          所以
          <h:commandLink action="view">
          <f:param id="productId" name="id" value="#{product.id}"/>
          </h:commandLink>
          <f:prarm>必須設(shè)置id
           
          Map params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
          String someValue = params.get("id"); 
          這個是按參數(shù)名稱查找的
          JSF標(biāo)簽只是JSF組件的外衣,Id就是組件的命名,與Delphi的組件名是一樣的,之所以用Id不用Name,是為了與HTML中的一致(HTML input組件 id是其標(biāo)識,name是其傳遞到服務(wù)器端的參數(shù)名。),所以查找JSF組件當(dāng)然用Id了。
           
          6.當(dāng)一個頁面的BackingBean的構(gòu)造函數(shù)中運行出錯或?qū)傩宰⑷氤鲥e時,表面上會報計算表達(dá)式錯誤,原因是這個BackingBean沒有構(gòu)造出來,為空,當(dāng)然在Reader頁面時會沒有辦法求相關(guān)的表達(dá)式的值。
           
           
          7.request級的BackingBean在從客戶端到服務(wù)端一次請求后,就被銷毀。在這次請求中,只會被創(chuàng)建一次。在Forward之前創(chuàng)建的BackingBean在Forward之后,并不會被再次創(chuàng)建。
           
          8.判斷是否是回傳。
          protected boolean isPostBack()
           {
            if (FacesContext.getCurrentInstance().getRenderResponse())
             return false;
            else
             return true;
           }
           
           
          9.<f:view>里使用<jsp:include>時的注意事項 
          感謝 tdwebber 提供。

          1) When using a jsp:include within the f:view tags, must include f:subview in the included file (or around the jsp:include tag).鯤鵬網(wǎng)

          當(dāng)在f:view中使用jsp:include標(biāo)簽插入一個文件時,

          http://www.kpwang.com/必須用f:subview把jsp:include包起來

           

          2) In the include file, cannot have any HTML. All HTML tags must be wrapped in f:verbatim tags.

          在被插入的文件中,不能有任何的html標(biāo)簽,如果必須使用html標(biāo)簽,必須用f:verbatim將它包起來。

          3) Within main f:view tags however, it is not necessary to wrap everything in f:verbatim tags (it´s not bad either). Just HTML that appears as children to other JSF components (i.e. t:newspaperTable).

          在主f:view中,沒有必要用f:verbatim將html標(biāo)簽包起來(當(dāng)然包起來也可以)。當(dāng)html標(biāo)簽出現(xiàn)在子視圖或其它JSF部件標(biāo)簽中時,就要用f:verbatim包起來。

          10.JSF的緩存能力好像太強(qiáng)了,有時停止了服務(wù)器,改動了jsp頁面中的jsf標(biāo)簽,再啟動服務(wù)器,但到該頁面時,還是原來的內(nèi)容,需要手動刷新一下。有時需要先轉(zhuǎn)到別的頁面,再回來刷新一下才能看到更新的內(nèi)容。

          posted on 2009-06-10 17:07 開花流水 閱讀(485) 評論(0)  編輯  收藏 所屬分類: jsf

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 水城县| 吴江市| 五指山市| 永康市| 内丘县| 金昌市| 松原市| 兰州市| 高阳县| 邹平县| 陈巴尔虎旗| 拉萨市| 金阳县| 申扎县| 双桥区| 澄江县| 墨竹工卡县| 内黄县| 桐乡市| 巢湖市| 长春市| 深水埗区| 鄂托克旗| 墨脱县| 章丘市| 扎兰屯市| 临澧县| 安福县| 洛南县| 怀化市| 安国市| 连城县| 西宁市| 广水市| 承德县| 古浪县| 杭锦旗| 林州市| 都昌县| 阿坝县| 镇远县|