如果没有在JDK1.5中设置ID,则无法从可编辑数据表更新绑定值

时间:2011-07-27 10:54:33

标签: java jsf jdk1.6 jdk1.5 jsf-1.2

如果没有在JDK 1.5中设置ID,则无法从可编辑数据表更新绑定值。但是在JDK 1.6中没有设置ID的情况下也可以。 有谁知道为什么?感谢

代码,Bean部分

    public void setDataTable(HtmlDataTable dataTable) {
    this.dataTable = dataTable;
}

public HtmlDataTable getDataTable() {
    if (dataTable == null)
        setEditableDataTable();
    return dataTable;
}

private void setEditableDataTable() {

    dataTable = new HtmlDataTable();
    dataTable.setValueBinding("value",
            createValuebinding("#{testBean.stringList}"));
    dataTable.setVar("items");
    for (int i = 0; i < getDatastable().get(i).size(); i++) {

        UIColumn column = new UIColumn();
        dataTable.getChildren().add(column);

        HtmlOutputText header = new HtmlOutputText();
        header.setValue("Header "+i);
        column.setHeader(header);

        HtmlInputText input = new HtmlInputText();
        input.setValueBinding("value", createValuebinding("#{items[" + i
                + "]}"));
        column.getChildren().add(input);

    }

}

private ValueBinding createValuebinding(String valueExpression) {
    return FacesContext.getCurrentInstance().getApplication()
            .createValueBinding(valueExpression);
}

JSP部分

   <h:dataTable binding="#{testBean.dataTable}" >
                </h:dataTable>

解决方案

   Give id for the datatable

0 个答案:

没有答案