动态自增表格rich:dataTable

页面

<rich:dataTable id="tb1" value="#{tbtest.tb}" var="tbmethod"
      width="600px">
      <f:facet name="header">
       <rich:columnGroup>
        <rich:column colspan="2">
         <h:outputText value="采集要素"></h:outputText>
        </rich:column>
       </rich:columnGroup>
      </f:facet>
      <rich:column>
       <f:facet name="header">
        <h:outputText value="值一"></h:outputText>
       </f:facet>
       <a4j:commandLink value="#{tbmethod.value1}" reRender="pp1"
        action="#{tbdb.selValue}" style="width:250px">
        <a4j:actionparam name="pa1" value="#{tbmethod.id}"
         assignTo="#{tbdb.id}" />
       </a4j:commandLink>
      </rich:column>
      <rich:column>
       <f:facet name="header">
        <h:outputText value="值二"></h:outputText>
       </f:facet>
       <h:outputText value="#{tbmethod.value2}" escape="false" style="width:250px"></h:outputText>
      </rich:column>
     </rich:dataTable>

 

java文件

private List<SetAllInfo> tb;

Map maps = FacesContext.getCurrentInstance().getExternalContext()
    .getSessionMap();

public TestTest() ...{
}

public void Add(SetAllInfo setinfo) ...{
   tb = new ArrayList<SetAllInfo>();
   List kk = (ArrayList) maps.get("xiaoyi");
   if (kk != null) ...{
    tb = kk;
   }
   if("".equals(setinfo.getValue1()))
   ...{
    setinfo.setValue1(" ");
   }
   if("".equals(setinfo.getValue2()))
   ...{
    setinfo.setValue2(" ");
   }
   tb.add(setinfo);
   maps.put("xiaoyi", tb);
}

public void del(long ids) ...{
   tb = (ArrayList) maps.get("xiaoyi");
   for (int i = 0; i < tb.size(); i++) ...{
    SetAllInfo ss = tb.get(i);
    if (ids == ss.getId()) ...{
     tb.remove(i);
     maps.put("xiaoyi", tb);
     break;
    }
   }
}

public void update(SetAllInfo info) ...{
   List<SetAllInfo> tbtemp = (ArrayList) maps.get("xiaoyi");
   for (int i = 0; i < tbtemp.size(); i++) ...{
    SetAllInfo sai = tbtemp.get(i);
    if (info.getId() == sai.getId()) ...{
     // tb.remove(i);
     // tb.add(i, info);
     tbtemp.set(i, info);
     tb = tbtemp;
     // tb.addAll(tbtemp);
     // tb=tbtemp;
     maps.put("xiaoyi", tb);
     break;
    }
   }
}

public SetAllInfo selElem(long flagRow) ...{
   SetAllInfo ss = new SetAllInfo();
   tb = new ArrayList<SetAllInfo>();
   List lis = (ArrayList) maps.get("xiaoyi");
   if (lis != null) ...{
    tb = lis;
    for (int i = 0; i < tb.size(); i++) ...{
     ss = tb.get(i);
     if (flagRow == ss.getId()) ...{
      break;
     }
    }
   }
   return ss;
}

public List<SetAllInfo> getTb() ...{
   tb = (ArrayList) maps.get("xiaoyi");
   return tb;
}

public void setTb(List<SetAllInfo> tb) ...{
   this.tb = tb;
} 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值