我正在尝试使用 Richfaces 3.3.Final 让 jsf 1.2 遗留项目工作。
我正在尝试使用动态列创建数据表,但出现错误:
Caused by: javax.el.PropertyNotFoundException: /index.xhtml @44,58 value="#{results[ind].columnName}": Property '0' not found on type ..../TableBean
我基本上遵循此页面中的示例 - http://livedemo.exadel.com/richfaces-demo/richfaces/columns.jsf?tab=usage&cid=278645但他们没有显示他们的支持 bean 代码。
这是我的相关代码
<rich:dataTable id="resultsTable" value="#{tableBacking.results}" var="results">
<f:facet name="header">
<h:outputText value="Results" />
</f:facet>
<rich:column>
<f:facet name="header">
<h:outputText value="First Columns" />
</f:facet>
</rich:column>
<rich:columns value="#{tableBacking.columns}" var="columns" index="ind" id="column#{ind}">
<f:facet name="header">
<h:outputText value="#{columns.header}" />
</f:facet>
<h:outputText value="#{results[ind].columnName}" />
</rich:columns>
</rich:dataTable>
支持豆
public class TableLookupBacking {
private List<ColumnModel> columns = null;
private List<TableBean> results = null;
public List<ColumnModel> getColumns() {
if(columns == null) {
columns = new ArrayList<ColumnModel>();
columns.add(new ColumnModel("header", "Property"));
columns.add(new ColumnModel("header2", "Property"));
columns.add(new ColumnModel("header3", "Property"));
System.out.println("columns.size = "+columns.size());
}
return columns;
}
public List<TableBean> getResults() {
if(results == null) {
results = new ArrayList<TableBean>();
results.add(new TableBean("id"));
results.add(new TableBean("name"));
System.out.println("results.size = "+results.size());
System.out.println("results.0 = "+results.get(0).getColumnName());
}
return results;
}
public void setResults(ArrayList<TableBean> results) {
this.results = results;
}
public void setColumns(ArrayList<ColumnModel> columns) {
this.columns = columns;
}
}
表豆
public class TableBean {
private String columnName;
public TableBean(String columnName) {
this.columnName = columnName;
}
public String getColumnName() {
return columnName;
}
public void setColumnName(String columnName) {
this.columnName = columnName;
}
}