带有数据表(动态列)的选项卡视图在primefaces中不起作用

时间:2014-06-30 22:30:07

标签: jsf jsf-2 primefaces

我正在尝试使用标签创建动态表。它似乎没有标签工作。但是当我将它与tabview一起使用时,列名列表不会被填充。我有多个选项卡,我试图为所有选项卡重用相同的代码。

 </ui:define>
    <ui:param name="menuTitle" value="Build Rule - Search" />
    <ui:define name="content">
        <h:body>
            <h:form prependId="false">
                <p:panel id="rulePanel"
                    style="margin: 0 auto; margin-top: 12px; width: 900px">
                    <p:tabView scrollable="true" var="test" value="#{tableBean.monDocTPBeanList}">
                        <p:tab title="Tab 1">
                            <p:dataTable var="rowName" value="#{test.rowNamesList}"
                                rowIndexVar="rowIdx">


                                <p:column headerText="" styleClass="ui-widget-header">
                                    <h:outputText value="#{rowName}" />
                                </p:column>

                                <p:columns var="columnName"     value="#{test.colNamesList}"    headerText="#{columnName}" columnIndexVar="colIdx">
                                    <ui:repeat value="#{test.data3D[rowIdx][colIdx]}"
                                        var="data">
                                        <p:panel>
                                            <h:outputText value="#{data}" />
                                        </p:panel>
                                    </ui:repeat>
                                </p:columns>
                            </p:dataTable>
                        </p:tab>
                    </p:tabView>
                </p:panel>
            </h:form>
        </h:body>
    </ui:define>

My bean class looks as below 


@ManagedBean(name = "tableBean")
@ViewScoped

public class TableBean implements Serializable{

    private static final long serialVersionUID = -1166918470591692944L;

    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>>>();

    private ArrayList<MonDocTpBean> monDocTPBeanList = new ArrayList<MonDocTpBean>();

    public ArrayList<MonDocTpBean> getMonDocTPBeanList() {
        return monDocTPBeanList;
    }

    public void setMonDocTPBeanList(ArrayList<MonDocTpBean> monDocTPBeanList) {
        this.monDocTPBeanList = monDocTPBeanList;
    }


    public TableBean() {

        rowNames.add("row1");
        rowNames.add("row2");

        colNames.add("col1");
        colNames.add("col2");
        colNames.add("col3");

        // Setup 3 dimensional structure
        ArrayList<MonDocTpBean> monDocTPBeanList1 = new ArrayList<MonDocTpBean>();

        for (int i = 0; i < rowNames.size(); i++) {
            data3D.add(new ArrayList<ArrayList<String>>());
            for (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");
        MonDocTpBean _MonDocBean = new MonDocTpBean();
        _MonDocBean.setColNamesList(colNames);
        _MonDocBean.setRowNamesList(rowNames);
        _MonDocBean.setData3D(data3D);
        MonDocTpBean _MonDocBean1=setValues();
        monDocTPBeanList1.add(_MonDocBean);
        monDocTPBeanList1.add(_MonDocBean1);

        this.setMonDocTPBeanList(monDocTPBeanList1);
    }

0 个答案:

没有答案