新的起點(diǎn) 新的開(kāi)始

          快樂(lè)生活 !

          ADF(ORACLE JEE 平臺(tái))中Table的顯示detail功能的使用

                  ADF(Application development Framework)是Oracle主推的JEE平臺(tái)的解決方案,其中包括JDeveloper (開(kāi)發(fā)IDE),Weblogic(Server 容器),ADF Faces(JSF 實(shí)現(xiàn)), ADF richFaces(JSF 中擴(kuò)展組件)等等。
          本文主要討論ADF Faces中,如何控制顯示Table的Details信息。

                  ADF Table類似于JSF標(biāo)準(zhǔn)的Table,但提供許多更有用的功能。比如顯示Datail就是很好的功能,如下圖:用戶可以點(diǎn)擊首列小圖表,查看本行詳細(xì)信息
                


          如下圖顯示:

          下面是相對(duì)應(yīng)的JSP和BackingBean

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd">
          <%@ page contentType="text/html;charset=GBK"%>
          <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
          <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
          <%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
          <%@ taglib uri="http://xmlns.oracle.com/adf/faces/html" prefix="afh"%>
          <f:view>
            
          <afh:html>
              
          <afh:head title="tableTest">
                
          <meta http-equiv="Content-Type" content="text/html; charset=GBK"/>
                
          <style type="text/css">
                body 
          {
          }

                a:link 
          { color: #ffa5a5; }
              
          </style>
              
          </afh:head>
              
          <afh:body>
                
          <h:form>
                  
          <af:table width="98%" value="#{tableTest.allData}" var="data"
                            emptyText
          ="No Data"
                            disclosureListener="#{tableTest.showDetails}"
           banding="none"
                            varStatus
          ="vs">
                    
          <af:column sortable="true" formatType="icon"
                               inlineStyle
          ="border-color:rgb(0,0,0); border-width:thin; margin:auto; text-align:center;">
                      
          <f:facet name="header">
                        
          <af:outputText value="NO."/>
                      
          </f:facet>
                      
          <af:outputText value="#{data.column1}"/>
                    
          </af:column>
                    
          <af:column  inlineStyle="border-color:rgb(0,0,0); border-width:thin; margin:auto; text-align:center;">
                      
          <f:facet name="header">
                        
          <af:outputText value="Last Name"/>
                      
          </f:facet>
                      
          <af:outputText value="#{data.column2}"/>
                    
          </af:column>
                    
          <af:column  inlineStyle="border-color:rgb(0,0,0); border-width:thin; margin:auto; text-align:center;">
                      
          <f:facet name="header">
                        
          <af:outputText value="First Name"/>
                      
          </f:facet>
                      
          <af:outputText value="#{data.column3}"/>
                    
          </af:column>
                    <f:facet name="detailStamp">
                      <af:panelGroup layout="vertical">
                        <af:outputText rendered="#{tableTest.showDetail}"
                                       value="#{data.detail}"/>
                         <af:outputText rendered="#{tableTest.showDetail}"
                                       value="#{data.detail}"/>
                          <af:outputText rendered="#{tableTest.showDetail}"
                                       value="#{data.detail}"/>

                      
          </af:panelGroup>
                    
          </f:facet>
                  
          </af:table>
                
          </h:form>
              
          </afh:body>
            
          </afh:html>
          </f:view>

          其中紅色部分JSP就是顯示Details信息。
          disclosureListener="#{tableTest.showDetails}" 為Table加一個(gè)打開(kāi)關(guān)閉Details信息的監(jiān)聽(tīng)器,在監(jiān)聽(tīng)器里面控制顯示。

          BackBean如下:

          public class TableDataBackBean {
              
          private List allData = new ArrayList();
              
          private boolean showDetail = false
              
          public TableDataBackBean() {
                  TableData tableDate1 
          = new TableData("1","vincent","ma","vincent ma'detail");
                  TableData tableDate2 
          = new TableData("2","barry","fan","barry fan'detail");
                  TableData tableDate3 
          = new TableData("3","jeny","chen","jeny chen'detail");
                  TableData tableDate4 
          = new TableData("4","ross","han","ross han'detail");
                  TableData tableDate5 
          = new TableData("5","robin","liu","robin liu'detail");
                  TableData tableDate6 
          = new TableData("6","walker","liu","walker liu'detail");
                  allData.add(tableDate1);
                  allData.add(tableDate2);
                  allData.add(tableDate3);
                  allData.add(tableDate4);
                  allData.add(tableDate5);
                  allData.add(tableDate6);

              
              }


              public void showDetails(DisclosureEvent disclosureEvent) {
                  if(disclosureEvent.isExpanded()){
                    this.showDetail = true;
                    }

              }


              
          public void setAllData(List allData) {
                  
          this.allData = allData;
              }


              
          public List getAllData() {
                  
          return allData;
              }


              
          public void setShowDetail(boolean showDetail) {
                  
          this.showDetail = showDetail;
              }


              
          public boolean isShowDetail() {
                  
          return showDetail;
              }

          }

          當(dāng)用戶點(diǎn)擊打開(kāi)小圖標(biāo)時(shí),觸發(fā)如下事件:
              public void showDetails(DisclosureEvent disclosureEvent) {
                  if(disclosureEvent.isExpanded()){
                    this.showDetail = true;
                    }
              }


          那么,如何只讓它顯示一個(gè)Detail 信息呢? 也就是打開(kāi)第二個(gè)時(shí),關(guān)閉第一個(gè)呢? 很簡(jiǎn)單
          修改showDetails方法如下:
              public String oldValue = "";
              
          public void showDetails(DisclosureEvent disclosureEvent) {
                  CoreTable activityTable1 
          = (CoreTable)disclosureEvent.getComponent();
                  
          if(disclosureEvent.isExpanded()){
                    
          this.showDetail = true;
                    }

                    
                  RowKeySet rowKeySet2  
          = activityTable1.getDisclosureState();
                    Set set 
          =rowKeySet2.getKeySet();
                    Iterator iterator 
          = set.iterator();
                    
          if(set.size()==2){
                       
          while(iterator.hasNext()){
                        String temp 
          = (String)iterator.next();
                           System.out.println(
          "Old Value:"+oldValue);
                        System.out.println(
          "Two value:"+temp);
                        
          if(!temp.equals(oldValue)){
                            oldValue 
          = temp;
                            System.out.println(
          "Set Older Value ="+temp);
                            
          break;
                        }

                       }

                       set.clear();
                       set.add(
          new String(oldValue));
                       System.out.println(
          "Display:"+oldValue);
                    }
          else if(set.size()==1){
                        
          while(iterator.hasNext()){
                         String temp 
          = (String)iterator.next();
                             oldValue 
          = temp;
                        }

                        set.add(
          new String(oldValue));
                        System.out.println(
          "only One Display:"+oldValue);
                    }


                    
                   activityTable1.setDisclosureState(rowKeySet2);
              }

          posted on 2009-08-02 21:00 advincenting 閱讀(1655) 評(píng)論(1)  編輯  收藏

          評(píng)論

          # re: ADF(ORACLE JEE 平臺(tái))中Table的顯示detail功能的使用 2009-08-04 12:23 個(gè)性藝術(shù)簽名

          斯柯達(dá)薩丹哈速度啊隨的  回復(fù)  更多評(píng)論   


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


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

          公告

          Locations of visitors to this pageBlogJava
        1. 首頁(yè)
        2. 新隨筆
        3. 聯(lián)系
        4. 聚合
        5. 管理
        6. <2009年8月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          統(tǒng)計(jì)

          常用鏈接

          留言簿(13)

          隨筆分類(71)

          隨筆檔案(179)

          文章檔案(13)

          新聞分類

          IT人的英語(yǔ)學(xué)習(xí)網(wǎng)站

          JAVA站點(diǎn)

          優(yōu)秀個(gè)人博客鏈接

          官網(wǎng)學(xué)習(xí)站點(diǎn)

          生活工作站點(diǎn)

          最新隨筆

          搜索

          積分與排名

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 九龙县| 昌乐县| 神农架林区| 乐东| 广德县| 巨野县| 桂林市| 内乡县| 公安县| 七台河市| 漳平市| 宁津县| 连平县| 浑源县| 江川县| 武义县| 凤山市| 逊克县| 鲁甸县| 石楼县| 文登市| 图片| 兖州市| 江北区| 图木舒克市| 杭州市| 汉川市| 博爱县| 酒泉市| 汾阳市| 延津县| 济南市| 洛阳市| 金门县| 胶南市| 陈巴尔虎旗| 吉首市| 岳西县| 科尔| 隆安县| 徐水县|