私は JSF 2.2 を使用しており、変数の属性を使用してパススルーtitle
で生成された各option
要素に属性を表示したいと考えています。h:selectOneMenu
f:selectItems
パススルー属性f:selectItems
をカスタマイズするための変数にアクセスできないようです
これが私がこれまでに行ったことです
表示するエンティティ
public class ItemBean {
private int id;
private String strName;
private String strDescription;
public ItemBean(int id, String strName, String strDescription) {
this.id = id;
this.strName = strName;
this.strDescription = strDescription;
}
// Getters and Setters
}
エンティティのリストを取得するためのバックビーン メソッド
public List<ItemBean> getItems() {
return new ArrayList<ItemBean>(){
{
add(new ItemBean(1, "Java", "Java programming language"));
add(new ItemBean(2, "PHP", "Yet another language"));
add(new ItemBean(3, "Python", "Not a snake at all"));
}
};
}
私h:selectOneMenu
の視界
<h:selectOneMenu>
<f:selectItems value="#{bean.items}" var="item"
itemValue="#{item.id}"
itemLabel="#{item.strName}"
p:title="Description : #{item.strDescription}"/>
</h:selectOneMenu>
item
問題は、の変数にアクセスできないことp:title
です。出力は空です。
生成されたコードは次のとおりです
<select>
<option title="Description : " value="1">Java</option>
<option title="Description : " value="2">PHP</option>
<option title="Description : " value="3">Python</option>
</select>
そのようにすることは可能ですか、それとも別の方法がありますか?