我正在尝试从arraylist填充数据表。在搜索了如何做之后,我发现我需要在jsf页面中将值属性设置为arraylist。这是我的托管bean的相关部分:
@ManagedBean(name = "customer")
@SessionScoped
public class Customer implements Serializable {
private String identityNumber;
private String password;
private List<Account> accounts;
}
我在jsf页面中的数据表定义:
<h:form>
<h:dataTable id="accountsTable" value="#{customer.accounts}"></h:dataTable>
问题是,它给出了“未知属性:帐户”的错误。它可以看到identityNumber和password属性,但它找不到accounts属性。谁能告诉我为什么并帮助我解决它?
由于
编辑:我解决了错误,但现在没有填充表格。这是代码:
<h:form>
<h:dataTable id="accountsTable" value="#{customer.accounts}" var="account">
<h:column>
<f:facet name="header">Account Number</f:facet>
#{account.accountNumber}
</h:column>
</h:dataTable>
</h:form>
答案 0 :(得分:2)
为accounts
列表定义getter和setter。从此错误中可以看出,unknown property: accounts
,accounts
无法显示。
public List<Account> getAccounts()
{
return accounts;
}
public void setAccounts(List<Account> accounts)
{
this.accounts = accounts;
}