0

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.00" 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?

A.W.
  • 2,858
  • 10
  • 57
  • 90

1 Answers1

1

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks, I will upgrade JSF. I'm using JBOss, Seam 2.1.2, Richfaces. In the Seam folders I see jsf-api.jar and jsf-impl.jar ( Mojarra JSF API Implementation 1.2_12-b01-FCS) But: when deploying I only see jsf-facelets.jar (Implementation-Version: 1.1.15.B1) I created my project using seam-gen I will look into how to upgrade it to 1.12 For the moment I will leave out: This causes the error. – A.W. May 28 '10 at 06:59
  • Could it be this is re-introduced in very recent JSF versions: https://stackoverflow.com/questions/54553332/fconvertnumber-on-double-classcastexception – Kukeltje Feb 12 '19 at 09:49
  • Looks like the same problem yes. – BalusC Feb 12 '19 at 12:09