cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Portier <...@outerthought.org>
Subject Re: Exception in form binding
Date Mon, 06 Sep 2004 10:08:01 GMT


Stephan Coboos wrote:

> Hello,
> 
> I have a form binding definition like this:
> 
>         <fb:value id="number" path="number">
>            <fd:convertor datatype="decimal"/>
>         </fb:value>
> 
> And a bean with the corresponding getter and setter methods:
> 
> public void setNumber(BigDecimal number)...
> public BigDecimal getNumber()...
> 

the specific conversion in binding is typically only needed when you 
bind to a string-only backend (ie when using xml over beans)

it works between the form-datatype en assumed strings on the backend.

above thus assumes fd:datatype of 'decimal' in combination with get/set 
string

> But when I tried to save my form into the bean I got an conversion 
> exception:
> 
> "org.apache.commons.jxpath.JXPathException: Exception trying to create 
> xpath number; Cannot modify property: foo.bar.model.Position.number; 
> Cannot convert value of class java.lang.String to type class 
> java.math.BigDecimal; Cannot convert class java.lang.String to class 
> java.math.BigDecimal"
> 
> The value of the form for the field "number" is just an integer value 
> like "3". What can I do, to convert the values from String to BigDecimal 
> corectly? I haven't found any solution.
> 

IIUC you should remove the convertor from the binding, and define your 
fd: type as being decimal

or, if it really is integers, keep the long datatype in your 
form-definition, and switch the types of your property (getter/setter) 
on the bean

> Thank you.
> 
HTH,
-marc=
-- 
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at                http://blogs.cocoondev.org/mpo/
mpo@outerthought.org                              mpo@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message