jsf - PrimeFaces 3 dimensional DataTable -


i have 2d datatable insert variable number of panels inside, creating 3d datatable.

the 2d table looks follows: 2d table ll

<p:datatable var="rowname" value="#{tablebean.rownames}">    <p:column headertext="" styleclass="ui-widget-header">       <h:outputtext value="#{rowname}"/>    </p:column>     <p:columns var="columnname" value="#{tablebean.colnames}" headertext="#{columnname}">       <p:panel>          <h:outputtext value="panel"/>       </p:panel>    </p:columns> </p:datatable> 

and java:

import javax.faces.bean.managedbean; import javax.faces.bean.requestscoped; import java.util.arraylist; import java.util.list;  @managedbean @requestscoped public class tablebean {     private list<string> rownames = new arraylist<string>();     private list<string> colnames = new arraylist<string>();     private arraylist<arraylist<arraylist<string>>> data3d = new arraylist<arraylist<arraylist<string>>>();      public tablebean() {         rownames.add("row1");         rownames.add("row2");          colnames.add("col1");         colnames.add("col2");         colnames.add("col3");          // setup 3 dimensional structure         (int = 0; < rownames.size(); i++) {             data3d.add(new arraylist<arraylist<string>>());             (int j = 0; j < colnames.size(); j++) {                 data3d.get(i).add(new arraylist<string>());             }         }          // row 1, col 1, 3 items         data3d.get(0).get(0).add("item1");         data3d.get(0).get(0).add("item2");         data3d.get(0).get(0).add("item3");          // row 1, col 2, 1 items         data3d.get(0).get(1).add("item1");          // row 1, col 3, 2 items         data3d.get(0).get(2).add("item1");         data3d.get(0).get(2).add("item2");          // row 2, col 1, 2 item         data3d.get(1).get(0).add("item1");         data3d.get(1).get(0).add("item2");          // row 2, col 2, 1 item         data3d.get(1).get(1).add("item1");     }      public list<string> getrownames() { return rownames; }     public void setrownames(list<string> rownames) { this.rownames = rownames; }      public list<string> getcolnames() { return colnames; }     public void setcolnames(list<string> colnames) { this.colnames = colnames; }      public arraylist<arraylist<arraylist<string>>> getdata3d() { return data3d; }     public void setdata3d(arraylist<arraylist<arraylist<string>>> data3d) { this.data3d = data3d; } } 

but achieve following, p1, p2, p3, etc primefaces panels:

+------+--------+--------+--------+-- |      |  col1  |  col2  |  col3  |  .... .... .... .... +------+--------+--------+--------+-- |      | +----+ | +----+ | +----+ | |      | | p1 | | | p1 | | | p1 | | |      | +----+ | +----+ | +----+ | | row1 | | p2 | |        | | p2 | | |      | +----+ |        | +----+ | |      | | p3 | |        |        | |      | +----+ |        |        | +------+--------+--------+--------+ |      | +----+ | +----+ |        | |      | | p1 | | | p1 | |        | | row2 | +----+ | +----+ |        | |      | | p2 | |        |        | |      | +----+ |        |        | +------+--------+--------+--------+ | .... | | .... |   .... 

is possible use 3rd dimension (list of strings) create panel each string, within each cell of datatable?

the solution rongnk suggested use ui:repeat.

by using brace notation [][], array 3rd dimension can specified. index of row , column can accessed rowindexvar , colindexvar attributes <p:datatable> , <p:columns> respectively.

<p:datatable var="rowname" value="#{tablebean.rownames}" rowindexvar="rowidx">     <p:column headertext="" styleclass="ui-widget-header">         <h:outputtext value="#{rowname}"/>     </p:column>      <p:columns var="columnname" value="#{tablebean.colnames}" headertext="#{columnname}"                columnindexvar="colidx">         <ui:repeat value="#{tablebean.data3d[rowidx][colidx]}" var="data">             <p:panel>                 <h:outputtext value="#{data}"/>             </p:panel>         </ui:repeat>     </p:columns> </p:datatable> 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -