Java學(xué)習(xí)

          java,spring,structs,hibernate,jsf,ireport,jfreechart,jasperreport,tomcat,jboss -----本博客已經(jīng)搬家了,新的地址是 http://www.javaly.cn 如果有對文章有任何疑問或者有任何不懂的地方,歡迎到www.javaly.cn (Java樂園)指出,我會盡力幫助解決。一起進步

           

          tomahawk JSF組件擴展組件(一)

          tomahawk JSF組件擴展組件(一)

          關(guān)鍵字: t

          <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

          一.資源文件的反編譯:native2ascii -reverse -encoding gb2313 b.properties a.properties

          二. <f:verbatim>組件用于將HTML元素添加到頁面中,并使 HTML 元素具有這些組件的行為。直接把HTML元素放在<h:panelGroup>中會發(fā)生錯誤,因為HTML元素并不是JSF的子組件。如果使 用 Faces Verbatim 組件,請確保遵循以下準(zhǔn)則:

          • IDE 使用的 JSP 頁中的代碼必須是對稱的、格式正確的XML,包括 <f:verbatim> 標(biāo)記內(nèi)的標(biāo)記。例如,在 <f:verbatim> 標(biāo)記中不能以 <table> 開頭,但可以將結(jié)束 </table> 標(biāo)記放在結(jié)束 </f:verbatim> 標(biāo)記后面。
          • <f:verbatim> 組件中不能嵌入其他 JavaServer Faces 組件。

          三.HTML編輯器組件:<t:inputHtml id="inputHtml" value="#{dvoFace.map['inputHtml']}" displayValueOnly="#{dvoFace.attribute}"/>

          四.Tomahawk 組件中的 forceId 屬性能使生成出來的組件ID不像JSF生成出來的form:cid 的形式,forceId="true"使生成出來的ID就是實際編寫的ID。

          五.<t:validate*/>組件中包含大量已定義的驗證:
            
          <t:validateEmail />        電子郵件驗證
              <t:validateCreditCard />    信用卡驗證
              <t:validateRegExpr pattern='\d{5}' />    使用正則表達式驗證
              <t:validateEqual for="equal" />        與id="equal"的組件組做相等驗證
          六.aliasBean和aliasBeanScope(aliasBeanScope組件里可以設(shè)置多個aliasBean組件.)組件可以為subview里有組件或頁面以別名的方式為當(dāng)前view傳遞bean
          <t:aliasBean alias="#{ali}" value="#{alibean}">
             <f:subview id="subviewer">
              <t:outputText forceId="true" id="ot" value="#{ali.name}"></t:outputText>
             </f:subview>
            </t:aliasBean>

          七.<t:buffer>組件的使用:

          <t:buffer into="#{buffer1}">
                  <t:div><h:outputText value="Buffer One"/></t:div>
          </t:buffer>
          <t:buffer into="#{buffer2}">
                  <t:div><h:outputText value="Buffer Two"/></t:div>
          </t:buffer>
          <h:outputText value="#{buffer2}" escape="false"/>
          <h:outputText value="#{buffer1}" escape="false"/>
          <h:outputText value="#{buffer2}" escape="false"/>
          它可以把內(nèi)容先緩沖起來,再用<h:outputText>組件顯現(xiàn)出來,這樣就可以把順序比較后的組件先render出來。
          八.在table的排序:

          Java代碼 復(fù)制代碼
          1. <t:dataTable styleClass="standardTable"  
          2.             headerClass="standardTable_SortHeader"  
          3.             footerClass="standardTable_Footer"  
          4.             rowClasses="standardTable_Row1,standardTable_Row2"  
          5.             var="car"  
          6.             value="#{list.cars}"  
          7.             sortColumn="#{list.sort}"  
          8.             sortAscending="#{list.ascending}"  
          9.             preserveDataModel="true"  
          10.             preserveSort="true">  
          11.   
          12.         <f:facet name="header">  
          13.             <h:outputText value="(header table)"  />  
          14.         </f:facet>  
          15.         <f:facet name="footer">  
          16.             <h:outputText value="(footer table)"  />  
          17.         </f:facet>  
          18.   
          19.         <h:column>  
          20.             <f:facet name="header">  
          21.                 <t:commandSortHeader columnName="type" arrow="true">  
          22.                     <h:outputText value="#{example_messages['sort_cartype']}" />  
          23.                 </t:commandSortHeader>  
          24.             </f:facet>  
          25.             <h:outputText value="#{car.type}" />  
          26.             <f:facet name="footer">  
          27.                 <h:outputText id="ftr1" value="(footer col1)"  />  
          28.             </f:facet>  
          29.         </h:column>  
          30.   
          31.         <h:column>  
          32.             <f:facet name="header">  
          33.                 <t:commandSortHeader columnName="color" arrow="true">  
          34.                     <h:outputText value="#{example_messages['sort_carcolor']}" />  
          35.                 </t:commandSortHeader>  
          36.             </f:facet>  
          37.             <h:outputText value="#{car.color}" />  
          38.             <f:facet name="footer">  
          39.                 <h:outputText id="ftr2" value="(footer col2)"  />  
          40.             </f:facet>  
          41.         </h:column>  
          42.   
          43. </t:dataTable>  

           list.sort:

          Java代碼 復(fù)制代碼
          1. protected void sort(final String column, final boolean ascending)  
          2. {  
          3.         Comparator comparator = new Comparator()  
          4.         {  
          5.             public int compare(Object o1, Object o2)  
          6.             {  
          7.                 SimpleCar c1 = (SimpleCar)o1;  
          8.                 SimpleCar c2 = (SimpleCar)o2;  
          9.                 if (column == null)  
          10.                 {  
          11.                     return 0;  
          12.                 }  
          13.                 if (column.equals("type"))  
          14.                 {  
          15.                     return ascending ? c1.getType().compareTo(c2.getType()) : c2.getType().compareTo(c1.getType());  
          16.                 }  
          17.                 else if (column.equals("color"))  
          18.                 {  
          19.                     return ascending ? c1.getColor().compareTo(c2.getColor()) : c2.getColor().compareTo(c1.getColor());  
          20.                 }  
          21.                 else return 0;  
          22.             }  
          23.         };  
          24.         Collections.sort(_cars, comparator);  
          25. }  

           

           

          posted on 2008-09-01 13:10 找個美女做老婆 閱讀(864) 評論(0)  編輯  收藏


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


          網(wǎng)站導(dǎo)航:
           

          導(dǎo)航

          統(tǒng)計

          公告

          本blog已經(jīng)搬到新家了, 新家:www.javaly.cn
           http://www.javaly.cn

          常用鏈接

          留言簿(6)

          隨筆檔案

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 五寨县| 卓资县| 麻江县| 辽阳市| 清苑县| 吴堡县| 交城县| 安陆市| 拉孜县| 中西区| 临安市| 仁化县| 大化| 赤城县| 噶尔县| 彭州市| 焦作市| 延津县| 阿拉善左旗| 台湾省| 汶川县| 大田县| 昔阳县| 龙陵县| 河池市| 靖宇县| 永川市| 灯塔市| 开封市| 阳曲县| 大竹县| 定襄县| 金乡县| 桐城市| 墨竹工卡县| 龙泉市| 婺源县| 蒙阴县| 监利县| 金寨县| 江门市|