を数値に binding するには?

を使ってちょっとはまっていたら,
同じようなことを POST している人がいた.

http://forums.java.sun.com/thread.jspa?threadID=604798&tstart=0

リプライはないようだけど...

コードを以下に引用.

<h:selectOneMenu  value="#{bean.num}">
  <f:selectItem itemValue="1" itemLabel="option1"/>
  <f:selectItem itemValue="2" itemLabel="option2"/>
  <f:selectItem itemValue="3" itemLabel="option3"/>
  <f:selectItem itemValue="4" itemLabel="option4"/>
</h:selectOneMenu>

JSF 1.0/1.1 RI だと num が数値型のプロパティだと,validation エラーとなってしまう.

とりあえずの解決策は,以下くらいか?

  1. に書き換え,options で,new SelectItem(new Integer(1), "option1") みたいした SelectItem の配列とかを返す
  2. UISelectOne/UISelectMany を置き換える.とりあえず validate() メソッドを実装しなおせば OK
  3. bean.num のプロパティを String が引数に渡されても適切に動作するクラスに変更する

しかし,どれも邪魔くさい...

MyFaces 1.0.8 だと,子供の UISelectItem/UISelectItems のチェックは未実装のよう.
#おっ,1.0.9 も出ている.こいつの実装はどうなってるのだろう...