1 Reply Latest reply on Dec 4, 2009 11:32 AM by Matthias Preier

    currency conversion

    valerio de minico Newbie

      I have a form with a currency field. This is the xhtml code for the currency field:

      <h:inputText id="prezzoMaxTextbox" required="true" value="#{camera.prezzoMax}">
            <f:convertNumber type="currency" locale="it" currencySymbol="€"/>

      In Italy the default decimal separator is comma: ex. € 10,80
      The value displayed into the field is correctly formatted, infact it shows € 0,00, using comma...
      When the user inputs a value, ex. € 19,90 , server returns this error:

      sourceId=addNewCameraForm:prezzoMaxDecoration:prezzoMaxTextbox[severity=(ERROR 2), summary=(/registration_camera.xhtml @87,98 value="#{camera.prezzoMax}": Can't set property 'prezzoMax' on class 'com.bbpoint.core.entity.Camera' to value '18,59'.), detail=(/registration_camera.xhtml @87,98 value="#{camera.prezzoMax}": Can't set property 'prezzoMax' on class 'com.bbpoint.core.entity.Camera' to value '18,59'.)]

      It seems that converter can't convert value inserted by the user into a float value and then set it to prezzoMax camera's field.

      Any solution???


        • 1. Re: currency conversion
          Matthias Preier Newbie

          I somehow discovert a similar problem with converting currencies. I try to do nearly the same thing, but with a german locale.

          <h:inputText id="chargeNet" required="true" value="#{courseHome.instance.chargeNet}">
               <f:convertNumber type="currency" />

          If I call my edit form, the value looks pretty good e.g. 300,00 €, but if I try to save this form without changes the following error occures:

          /view/course-edit.xhtml @39,109 value="#{courseHome.instance.chargeNet}": java.lang.IllegalArgumentException: argument type mismatch

          Even if I try to set the value for a new entity. I tryed many combinations, w/wo currency symbol, w/wo comma, but nothing seems to work. My value property is a BigDecimal.

          There must be a way to insert and validate currency values.

          Thanks, Matthias.