UISelectItemGroup
コンポーネントについて
UISelectItemGroup
コンポーネントは、複数のUISelectItem
コンポーネントをグループ化するために使用します。グループは、次のようにBean内に定義します。
次の属性を使用して、グループに対する変数を作成します。
たとえば、2つのグループ(保険給付金を示すグループと共済金を示すグループ)を作成する場合、Beanのコードは次のようになります。
private SelectItemGroup insurance =
{
new SelectItemGroup("Insurance", //value
"types of insurance", //description
false, //disabled
insuranceItems); //select items
}
private SelectItemGroup financial =
{
new SelectItemGroup("Financial Benefits", // value
"financial benefits", // description
false, //disabled
financialItems); //select items
次に、SelectItem
コンポーネントの配列としてグループSelectItem
を定義します。
たとえば、保険項目のリストを作成する場合、コードは次のようになります。
private SelectItem[] insuranceItems =
{
new SelectItem("Health"),
new SelectItem("Vision"),
new SelectItem("Dental"),
};
次に、リスト全体へのアクセスに使用するSelectItem
コンポーネントを定義します。このコンポーネントに組み込む必要があるのは、グループ変数のみです。
たとえば、リスト全体にアクセスしてインスタンス化する場合、コードは次のようになります。
public SelectItem[] getBenefits()
{
return benefits;
}
private SelectItem[] benefits =
{
insurance, financial
};
selectItems
タグを使用してJSPページからリストにアクセスするには、そのリストに対するSelectItem
への値バインディングを使用します。
JSPのコードは次のようになります。
<h:selectManyListbox>
<f:selectItems value="#{employees.benefits}"/>
</h:selectManyListbox>
Copyright © 1997, 2007, Oracle. All rights reserved.