0

配列リストからデータテーブルを作成しようとしています。その方法を検索した後、jsfページでvalue属性を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>
4

1 に答える 1

2

リストのゲッターとセッターを定義しますaccounts。このエラーから見えるようにunknown property: accountsaccountsは表示できません。

public List<Account> getAccounts()
{
        return accounts;
}

public void setAccounts(List<Account> accounts)
{
        this.accounts = accounts;
}
于 2013-07-06T13:53:08.280 に答える