jsf h:inputText and Double value
I use:
<h:inputText id="costsPerPallet" value="#{globalReportSelectionForm.palletCost}" size="5">
<f:convertNumber pattern="0.00"/>
</h:inputText>
palletCost is a Double;
When entering a value of "1.0开发者_StackOverflow社区0" and submit it is fine. When I enter "1" and submit I get the error:
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Double
What is a good way to put "1.00" before the submit. In the onblur javascript function? Or is there a better way?
Works fine here on JSF Mojarra 1.2_14 and 2.0.2. So I think it's a bug in one of the ancient versions and that you need to upgrade your JSF version. You may also try to explicitly convert it as Double
as follows.
<h:inputText converterId="javax.faces.Double">
Not sure if that works though. Upgrading your JSF impl to latest build is definitely worth it.
精彩评论