You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Mark Lundquist <ml...@comcast.net> on 2005/06/04 02:14:43 UTC

[forms] simple output-only datatype convertor

Hi,

I have this class called Money, a fixed-point representation and 
arithmetic class for monetary amounts.

I want to display some Moneys in an <output> widget in a <repeater>.

Money has a toString() method.

Am I missing some obvious, built-in easy way to make this work?

What I did...
(1) Wrote dumb little class StringConvertor and StringConvertorBuilder 
classes.  This just calls toString() on the object.  I added this in 
the Cocoon source tree.
(2) Made a MoneyType and MoneyTypeBuilder (extending the abstract 
classes in oacf.datatype.typeimpl).  I did this in my application 
source tree which is built separately from cocoon.  To make this work, 
I had to change visibility on some AbstractTypeBuilder methods from 
protected to public.
(3) Finally, added my new datatype to cocoon.xconf.

It works fine.

But it feels wrong.  It was kind of a pain in the rear for one thing.  
Was there a better approach?

Cheers,
—ml—