Java学习

java,spring,structs,hibernate,jsf,ireport,jfreechart,jasperreport,tomcat,jboss -----本博客已经搬家了,新的地址是 http://www.javaly.cn 如果有对文章有任何疑问或者有任何不懂的地方,欢迎到www.javaly.cn (Java乐园)指出,我会尽力帮助解决。一起进步

 

tomahawk JSF组件扩展组件(二)

tomahawk JSF组件扩展组件(二)

关键字: t

九.使用DataModel作为table的列或数据。

Java代码 复制代码
  1. List headerList = new ArrayList();  
  2.         headerList.add(new ColumnHeader("Index","100",false));  
  3.         headerList.add(new ColumnHeader("Type","200",true));  
  4.         headerList.add(new ColumnHeader("Model","300",true));  
  5.         columnHeaders = new ListDataModel(headerList);  
  6.   
  7. List rowList = new ArrayList();  
  8.         for (int i = 100; i <= 999; i++)  
  9.         {  
  10.             List colList = new ArrayList();  
  11.             colList.add(new Integer(i));  
  12.             colList.add("Car Type " + i);  
  13.             colList.add((i%2==0) ? "blue" : "green");  
  14.             rowList.add(colList);  
  15.         }  
  16.         data = new ListDataModel(rowList);  
  17.   
  18. public void setColumnValue(Object value)  
  19.     {  
  20.       if (data.isRowAvailable() && columnHeaders.isRowAvailable())  
  21.       {  
  22.           ((List)data.getRowData()).set(columnHeaders.getRowIndex(), value);  
  23.       }  
  24.     }  
  25.   
  26.     public String getColumnWidth()  
  27.     {  
  28.         String columnWidth = null;  
  29.         if (data.isRowAvailable() && columnHeaders.isRowAvailable())  
  30.         {  
  31.             columnWidth = ((ColumnHeader)columnHeaders.getRowData()).getWidth();  
  32.         }  
  33.         return columnWidth;  
  34.     }  

 再动态地在<t:datatable>中生成列与行数据:

Java代码 复制代码
  1. <t:columns id="columns" value="#{openDataList.columnHeaders}"   
  2.                   var="columnHeader" style="width:#{openDataList.columnWidth}px">  
  3.     <f:facet name="header">  
  4.         <t:commandSortHeader columnName="#{columnHeader.label}" arrow="false" immediate="false">  
  5.             <f:facet name="ascending">  
  6.                 <t:graphicImage value="images/ascending-arrow.gif" rendered="true" border="0"/>  
  7.             </f:facet>  
  8.             <f:facet name="descending">  
  9.                 <t:graphicImage value="images/descending-arrow.gif" rendered="true" border="0"/>  
  10.             </f:facet>  
  11.             <h:outputText value="#{columnHeader.label}" />  
  12.         </t:commandSortHeader>  
  13.     </f:facet>  
  14.     <!-- row is also available -->  
  15.     <h:inputText rendered="#{openDataList.valueModifiable}" value="#{openDataList.columnValue}" />  
  16.     <h:outputText rendered="#{!openDataList.valueModifiable}" value="#{openDataList.columnValue}" />  
  17. </t:columns>  

 十.<t:panelTabbedPane>的使用

Java代码 复制代码
  1. <t:panelTabbedPane bgcolor="#FFFFCC" >  
  2.     <!-- 所有tab都有组件写在panelTab组件的前面-->  
  3.     <f:verbatim><p></f:verbatim>  
  4.     <h:outputText value="#{example_messages['tabbed_common']}"/>  
  5.     <f:verbatim></p></f:verbatim>  
  6.     <t:panelTab id="tab1" label="#{example_messages['tabbed_tab1']}"   
  7.                     rendered="#{tabbedPaneBean.tab1Visible}">  
  8.         <h:selectBooleanCheckbox id="testCheckBox" value="#{testCheckBox.checked}"/>  
  9.         <h:outputLabel for="testCheckBox" value="A checkbox"/>  
  10.         <f:verbatim><br/><br/></f:verbatim>  
  11.         <h:inputText id="inp1"/><f:verbatim><br></f:verbatim>  
  12.         <h:inputText id="inp2" required="true" />  
  13.         <h:message for="inp2" showSummary="false" showDetail="true" />  
  14.     </t:panelTab>  
  15.     <f:subview id="tab2" >  
  16.         <jsp:include page="tab2.jsp"/>  
  17.     </f:subview>  
  18. </t:panelTabbedPane>  

十一.js日期弹出式组件<t:inputCalendar>

Java代码 复制代码
  1. <t:inputCalendar monthYearRowClass="yearMonthHeader" weekRowClass="weekHeader"  
  2.                 currentDayCellClass="currentDayCell" value="#{calendarBean.secondDate}"   
  3.                 renderAsPopup="true" popupTodayString="#{example_messages['popup_today_string']}"   
  4.                 popupWeekString="#{example_messages['popup_week_string']}"  
  5.                 renderPopupButtonAsImage="true" />  

 十二.jscookmenu的使用。

Java代码 复制代码
  1. <t:jscookMenu layout="hbr" theme="ThemeOffice">  
  2.     <%/* Availaible jscookMenu themes: ThemeIE, ThemeMiniBlack, ThemeOffice, ThemePanel 
  3.              Availaible jscookMenu layout: hbr, hbl, hur, hul, vbr, vbl, vur, vul 
  4.              respect to Heng Yuan http://www.cs.ucla.edu/~heng/JSCookMenu 
  5.     */%>  
  6.     <t:navigationMenuItem id="nav_1"  
  7.             itemLabel="#{example_messages['nav_Home']}" action="go_home" />  
  8.     <t:navigationMenuItem id="nav_2"  
  9.             itemLabel="#{example_messages['nav_Examples']}">  
  10.             <t:navigationMenuItem id="nav_2_1"  
  11.                    itemLabel="#{example_messages['nav_Sample_1']}" action="go_sample1" />  
  12.     </t:navigationMenuItem>  
  13.  </t:jscookMenu>  

 十三.<t:panelNavigation2>组件:

Java代码 复制代码
  1. <t:panelNavigation2 id="nav1" layout="list" itemClass="mypage"   
  2.                                  activeItemClass="selected" openItemClass="selected" >  
  3.   <t:commandNavigation2 value="#{example_messages['panelnav_products']}" action="" >  
  4.             <t:commandNavigation2 action="go_panelnavigation_1" >  
  5.                 <f:verbatim>› </f:verbatim>  
  6.                 <t:outputText value="#{example_messages['panelnav_serach1']}" />  
  7.             </t:commandNavigation2>  
  8.             <t:commandNavigation2 action="go_panelnavigation_1" >  
  9.                 <f:verbatim>› </f:verbatim>  
  10.                 <t:outputText value="#{example_messages['panelnav_serach_acc1']}" />  
  11.             </t:commandNavigation2>  
  12.             <t:commandNavigation2 action="go_panelnavigation_1" >  
  13.                 <f:verbatim>› </f:verbatim>  
  14.                 <t:outputText value="#{example_messages['panelnav_search_adv1']}" />  
  15.             </t:commandNavigation2>  
  16.         </t:commandNavigation2>  
  17.         <t:commandNavigation2 value="#{example_messages['panelnav_shop']}" action="" />  
  18.   
  19. </t:panelNavigation2>  

 也可以动态地生成navigationMenuItem:

Java代码 复制代码
  1. <t:panelNavigation2 id="nav1" layout="list" itemClass="mypage" activeItemClass="selected" openItemClass="selected" >  
  2.         <t:navigationMenuItems value="#{navigationMenu.panelNavigationItems}" />  
  3.     </t:panelNavigation2>  
  4.   
  5. panelNavigationItems方法:  
  6.   
  7. public List getPanelNavigationItems() {  
  8.         List menu = new ArrayList();  
  9.         // Products  
  10.         NavigationMenuItem products = getMenuNaviagtionItem("#{example_messages['panelnav_products']}"null);  
  11.         menu.add(products);  
  12.         products.add(getMenuNaviagtionItem("#{example_messages['panelnav_serach']}""#{navigationMenu.getAction2}"));  
  13.         products.add(getMenuNaviagtionItem("#{example_messages['panelnav_serach_acc']}""#{navigationMenu.getAction2}"));  
  14.         NavigationMenuItem item = getMenuNaviagtionItem("#{example_messages['panelnav_search_adv']}""#{navigationMenu.getAction2}");  
  15.         item.setActive(true);  
  16.         item.setOpen(true);  
  17.         item.setTarget("_blank");  
  18.         products.add(item);  
  19.         // Shop  
  20.         menu.add(getMenuNaviagtionItem("#{example_messages['panelnav_shop']}""#{navigationMenu.getAction2}"));  
  21.         // Corporate Info  
  22.         NavigationMenuItem corporateInfo = getMenuNaviagtionItem("#{example_messages['panelnav_corporate']}"null);  
  23.         menu.add(corporateInfo);  
  24.         corporateInfo.add(getMenuNaviagtionItem("#{example_messages['panelnav_news']}""#{navigationMenu.getAction2}"));  
  25.         item = getMenuNaviagtionItem("#{example_messages['panelnav_investor']}""#{navigationMenu.getAction3}");  
  26.         //item.setIcon("images/arrow-first.gif");  
  27.         item.setDisabled(true);  
  28.         corporateInfo.add(item);  
  29.         // Contact  
  30.         menu.add(getMenuNaviagtionItem("#{example_messages['panelnav_contact']}""#{navigationMenu.getAction2}"));  
  31.         // External Link  
  32.         item = getMenuNaviagtionItem("#{example_messages['panelnav_contact']}"null);  
  33.         item.setExternalLink("#{example_messages['external_link']}");  
  34.         item.setTarget("_blank");  
  35.         menu.add(item);  
  36.         return menu;  
  37.     }  

posted on 2008-09-01 13:11 找个美女做老婆 阅读(663) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

公告

本blog已经搬到新家了, 新家:www.javaly.cn
 http://www.javaly.cn

常用链接

留言簿(6)

随笔档案

文章档案

搜索

最新评论

阅读排行榜

评论排行榜