I don't know if my understanding of the purpose of
ActionForm is correct, but I have been treating them
as part of the View. Hence I have been designing the
APIs of ActionForm with the needs of the JSP(s) in
mind. For example, all attributes bound to text
fields are declared as Strings. My ActionForms
function as adapters to the model JavaBeans and EJBs,
they are responsible for necessary type convertions.
For example, field "dateOfBirth" is always declared as
String on the ActionForm, but as Date on the model
bean. An action method (e.g. "save()") pushes data
into the model, converting types as needed. When my
ActionForm needs nested objects, I create new,
UI-oriented classes for those as well.
If my understanding of the role of ActionForms is
right, no enhancement of the form population mechanism
is needed.
Do you think this approach is an overkill?
- Dmitri Plotnikov
Chris Lai wrote:
The other problem on form population is that if an
alphanumeric string (form
user input) is assigned to the int or long form
property. Since the string
is an invalid number, the convertUtils will covert
the data to 0 which is
incorrect.
Since the form population occur before the form
validation, we lost the
information for incorrect user input. So I think
there has to be some sort
of validation before the form population. Otherwise
the user of form bean is
pretty limited.
This validation is more important if nested property
is used to set the
property of a business object inside the form bean.
Since the set method on
the business object may already contain the
validation, an exception may be
thrown (from the set method of the business object)
in the form population.
Is there any plan to enchance the form population in
the future struts
release?
-----Original Message-----
From: Jim Richards [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 16, 2001 5:33 PM
To: [EMAIL PROTECTED]
Subject: Re: Form population
I'm pretty sure it was all as expected. Although I
find it
interesting that it works with "int" rather then
"Integer",
from what I saw of the code.
I've changed it all the String and it works now, but
I was
poking around in BeanUtils and PropertyUtils and so
on (don't have
the reference here) and it seems that for nested
properties
it only handles a String (haven't fully checked it
yet).
"Natra, Uday" wrote:
>
> yeah that was a good point from Dmitri. I tried to
define two setter
methods
> for my date field. one is a String argument and
the other one is a date
> argument. When I ran the App, it complained about
not able to find the
> setter method. So may be there is some thing like
that happening in ur
code.
>
> Thanks,
> Uday.
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/