- <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;
- }