开发者

JSF h:SelectOneMenu does not convert to Number

I am using Sun JSF-RI 1.2 and having grief with h:SelectOneMenu. The value is bound to a backing bean field of type Object.

<h:selectOneMenu value="#{bean.currentNumber}">
  <f:selectItems value="#{bean.numberList}" />
</h:selectOneMenu> 

The SelectItems are created as follows:

SelectItem option = new SelectItem(new Double(3),"3");

I expect my backing bean to be injected with an object of type Double but instead all I get is a String "3"

I believe JSF should convert it correctly, other wise what is the point in having a

SelectItem(Object val,String label)

Constructor, if all its开发者_运维百科 good for is strings

Please help !!!

Thanks :)


Change the type from Object to Double or add converter="javax.faces.Double" to the <h:selectOneMenu>.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜