Craig,

I use the opportunity to jump into this and to ask you and everybody here
for an advice:

I try to follow the good practice to have only Strings within the
form-classes and having value objects with the correct types.

In the past I coded the copy from vo to form and vice-versa with the typical
setter-getter for every field - easy but sometimes painfull.

Recently I've started using BeanUtils to copy the properties, I even ;-)))
managed it to register my own converter for GregorianCalendar properties.

Now my two questions/problems:

question 1:
where do i need to register the converter in a struts web-application? once
in a plugin? within the the controller? within every action?

problem/question 2:
when i have the typical situation of vaqlue object "invoice"  having an
ArrayList of value objects "invoice position" and having a form "invoice"
with an ArrayList of "subforms" "invoice position", then the copyProperties
works fine for the vo-invoice to form-invoice but it copes the
vo-invoice-positions to the ArrayList of the form-invoice.
is there a solution for this problem?
is there a possibility to ask the converter not to convert collections?
what is a good practice to manage this?


-Rene



> -----Original Message-----
> From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> Sent: Dienstag, 7. Januar 2003 21:28
> To: Struts Users Mailing List
> Subject: Re: ConvertUtils, Null Integers
>
>
>
>
> On Tue, 7 Jan 2003, Jim Krygowski wrote:
>
> > Date: Tue, 07 Jan 2003 09:00:04 -0500
> > From: Jim Krygowski <[EMAIL PROTECTED]>
> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> > To: Struts Users Mailing List <[EMAIL PROTECTED]>
> > Subject: ConvertUtils, Null Integers
> >
> > Hi-
> >
> > This might be a question to Craig specifically, but I'd
> appreciate hearing
> > from anyone with experience.  I noticed that the
> ConvertUtils instructs
> > IntegerConverter to create Integer objects with the default
> value of 0 when
> > it can't convert what it receives into a proper Integer.
> The application
> > I'm building with Struts has several forms that must
> support "null" values.
> > That is, fields in which no entries are made.  The
> underlying database
> > fields are nullable and zero is a significant and
> meaningfull number.
> >
> > Using the Struts infrastructure as is, form fields
> containing nothing are
> > converted to zero by ConvertUtils/IntegerConverter thus
> messing up my data
> > somewhat.
> >
> > Is there any way to get the Converter to set the Integer to
> null when the
> > value recieved from the HTML form isn't a valid integer?
> I'm aware of the
> > approach of creating my own custom Integer converter and
> loading it in a
> > static intializer but is there a better way?  Preferably
> some way that's
> > configurable via an xml file?
> >
>
> You can make Struts act like this by registering your own
> Converter, but
> you are ***much*** better off by keeping the property as a
> String in your
> form bean.  No only can you then distinguish between a
> zero-length String
> and a "0", it also doesn't screw things up when the user types garbage
> like "1a3" instead of "123".
>
> > thanks.
>
> Craig
>
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to