cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dumon <>
Subject Re: [cforms] writing my own data type
Date Wed, 24 Mar 2004 18:01:27 GMT
On Wed, 2004-03-24 at 16:05, Joerg Heinicke wrote:
> I'm trying to write my own data type implementation, but I fail on access
> restrictions in the AbstractDataType of Woody/Cocoon Forms.
> I want to have a data type that's based on long and formatted as currency,
> similar to the one already existing, but
> 1. working:
> When having
>   <wd:datatype base="long">
>     <wd:convertor type="formatting" variant="currency"/>
>   </wd:datatype>
> in the form definition I get my amount nicely formatted, but can not save it
> back. Even a value '123' ends in a ParseException. As I do not want to dive into
> XReporter I decided to write my own one without XReporter.

The formatting convertors simply use the java.text.DecimalFormat class
(the xreporter classes used there are simply a small wrapper to either
use the JDK version of that class or the one that ships with IBM's ICU4J

> 2. and not ignoring cents:
> When having the long value 1234567 it gets formatted as "1.234.567,00 €",
> meaning that I can never save cents. It should be "12.345,67 €".

How can it possibly know that the value you entered should be divided by

Anyway, don't you need only a custom convertor? A long stays a long I

> Back to the actual problem:
> I extended AbstractDataType and AbstractDataTypeBuilder and copied more or less
> the LongType and LongTypeBuilder. But I fail at
>     type.setArrayType(arrayType);
>     type.setBuilder(this);
> as these both methods have default access. Is there any specific reason for it?
> Even passing arrayType and this to the constructor of my AmountType would only
> work if the methods would have protected access. So what about changing the
> access of those methods to at least protected, maybe public?

protected seems good, I don't know why I didn't make them protected.

> Some comments on the existing long/formatting/currency issue?
> Regards,
> Joerg
Bruno Dumon                   
Outerthought - Open Source, Java & XML Competence Support Center                

View raw message