在辅助bean中创建动态可编辑数据表?

时间:2012-12-03 00:10:49

标签: java jsf primefaces

我正在尝试在辅助bean中创建一个带有输入的数据表,但显然这些值没有更新......

JSF代码:

<h:form id="formTest" >
     <h:panelGroup binding="#{backingAlgoritmo.panelGroup}" />
</h:form>

支持bean代码:

public HtmlPanelGroup getPanelGroup() {


    panelGroup = new HtmlPanelGroup();

    panelGroup.getChildren().add(getDataTableCromossomos());

    HtmlCommandButton saveButton = new HtmlCommandButton();
    saveButton.setId("save"); 
    saveButton.setValue("Save");
    saveButton.setActionExpression(
            createActionExpression("#{algGeneticoBean.executa()}", null));
    panelGroup.getChildren().add(saveButton);

    return panelGroup;

}



public DataTable getDataTableCromossomos() {
    dataTableCromossomos = new DataTable();
    dataTableCromossomos.setValueExpression("value", createValueExpression("#{algGeneticoBean.algoritmo.populacaoInicial.cromossomos}", List.class));
    dataTableCromossomos.setVar("c");

    if (algGeneticoBean != null) {
        int cont = 0;
        for (int i = 0; i < algGeneticoBean.getQtdGenes(); i++) {
            Column column = new Column();
            dataTableCromossomos.getChildren().add(column);

            HtmlInputText input = new HtmlInputText();
            input.setValueExpression("value", createValueExpression("#{c.genes.get(" + i + ").valorGeneString}", String.class));
            input.setRequired(true);
            input.setSize(2);
            System.out.println("#{c.genes.get(" + i + ").valorGene}");
            column.getChildren().add(input);


        }
    }

    return dataTableCromossomos;
}

创建了dataTable,但是当我提交表单时,bean中的值不会更新

我正在使用primefaces 3.3.1

有什么想法吗?

非常感谢

0 个答案:

没有答案