datatable

来源:互联网 发布:江西科技学院网络选课 编辑:程序博客网 时间:2024/05/16 08:49
  1. <rich:dataTableid="tb1"value="#{tbtest.tb}"var="tbmethod" 
  2.       width="600px"> 
  3.       <f:facetname="header"> 
  4.        <rich:columnGroup> 
  5.         <rich:columncolspan="2"> 
  6.          <h:outputTextvalue="采集要素"></h:outputText> 
  7.         </rich:column> 
  8.        </rich:columnGroup> 
  9.       </f:facet> 
  10.       <rich:column> 
  11.        <f:facetname="header"> 
  12.         <h:outputTextvalue="值一"></h:outputText> 
  13.        </f:facet> 
  14.        <a4j:commandLinkvalue="#{tbmethod.value1}"reRender="pp1" 
  15.         action="#{tbdb.selValue}"style="width:250px"> 
  16.         <a4j:actionparamname="pa1"value="#{tbmethod.id}" 
  17.          assignTo="#{tbdb.id}"/> 
  18.        </a4j:commandLink> 
  19.       </rich:column> 
  20.       <rich:column> 
  21.        <f:facetname="header"> 
  22.         <h:outputTextvalue="值二"></h:outputText> 
  23.        </f:facet> 
  24.        <h:outputTextvalue="#{tbmethod.value2}"escape="false"style="width:250px"></h:outputText> 
  25.       </rich:column> 
  26.      </rich:dataTable> 

java文件

Java代码 复制代码 收藏代码
  1. private List<SetAllInfo> tb;  
  2.  
  3. Map maps = FacesContext.getCurrentInstance().getExternalContext()  
  4.     .getSessionMap();  
  5.  
  6. public TestTest() ...{  
  7. }  
  8.  
  9. public void Add(SetAllInfo setinfo) ...{  
  10.    tb = new ArrayList<SetAllInfo>();  
  11.    List kk = (ArrayList) maps.get("xiaoyi");  
  12.    if (kk != null) ...{  
  13.     tb = kk;  
  14.    }  
  15.    if("".equals(setinfo.getValue1()))  
  16.    ...{  
  17.     setinfo.setValue1(" ");  
  18.    }  
  19.    if("".equals(setinfo.getValue2()))  
  20.    ...{  
  21.     setinfo.setValue2(" ");  
  22.    }  
  23.    tb.add(setinfo);  
  24.    maps.put("xiaoyi", tb);  
  25. }  
  26.  
  27. public void del(long ids) ...{  
  28.    tb = (ArrayList) maps.get("xiaoyi");  
  29.    for (int i =0; i < tb.size(); i++) ...{  
  30.     SetAllInfo ss = tb.get(i);  
  31.     if (ids == ss.getId()) ...{  
  32.      tb.remove(i);  
  33.      maps.put("xiaoyi", tb);  
  34.      break;  
  35.     }  
  36.    }  
  37. }  
  38.  
  39. public void update(SetAllInfo info) ...{  
  40.    List<SetAllInfo> tbtemp = (ArrayList) maps.get("xiaoyi");  
  41.    for (int i =0; i < tbtemp.size(); i++) ...{  
  42.     SetAllInfo sai = tbtemp.get(i);  
  43.     if (info.getId() == sai.getId()) ...{  
  44.      // tb.remove(i);  
  45.      // tb.add(i, info);  
  46.      tbtemp.set(i, info);  
  47.      tb = tbtemp;  
  48.      // tb.addAll(tbtemp);  
  49.      // tb=tbtemp;  
  50.      maps.put("xiaoyi", tb);  
  51.      break;  
  52.     }  
  53.    }  
  54. }  
  55.  
  56. public SetAllInfo selElem(long flagRow) ...{  
  57.    SetAllInfo ss = new SetAllInfo();  
  58.    tb = new ArrayList<SetAllInfo>();  
  59.    List lis = (ArrayList) maps.get("xiaoyi");  
  60.    if (lis != null) ...{  
  61.     tb = lis;  
  62.     for (int i =0; i < tb.size(); i++) ...{  
  63.      ss = tb.get(i);  
  64.      if (flagRow == ss.getId()) ...{  
  65.       break;  
  66.      }  
  67.     }  
  68.    }  
  69.    return ss;  
  70. }  
  71.  
  72. public List<SetAllInfo> getTb() ...{  
  73.    tb = (ArrayList) maps.get("xiaoyi");  
  74.    return tb;  
  75. }  
  76.  
  77. public void setTb(List<SetAllInfo> tb) ...{  
  78.    this.tb = tb;  
  79. }  
原创粉丝点击