struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hubert Rabago <hrab...@gmail.com>
Subject Re: [FORMDEF] Combining FormDef and Struts form definitions
Date Wed, 02 Nov 2005 20:32:14 GMT
On 11/2/05, Michael Jouravlev <jmikus@gmail.com> wrote:
>
> If it were possible to use form definitions made in struts-config.xml,
> then you would not have to reimplement this property in FormDef, and I
> would not have to wait for you to reimplement it ;-) I would just
> apply your patch to my copy of DynaActionForm, and FormDef would pick
> up transparently whatever properties are defined in struts-config.xml.
> Is it possible at all? Or is it too much work?

I've wondered about this feature, but there are some problems.  (Not
to mention, this is the first time someone asked for it).  For
instance, what if the form defined isn't a DynaBean?  And how would I
let the user specify formatting requirements (for dates, numbers,
etc)?

Still, it's feasible.  It's just sort of a reversal of what I tried to
do.  I wanted to reduce config info.  If you defined your form one
field at a time in struts-config, then defined them again in
formdef-config, then you end up with two places you have to keep in
sync.  Not to mention validation.xml (if you were using it for that
form).

With the form defined in FormDef, you're sure the fields on the bean
are represented on the form, and they're always in sync.  Form field
types already default to java.lang.String.  You can even put
validation rules right there!

> In a way, this is similar to explicitly supporting all HTML tag
> attributes in Struts tags instead of supporting whatever a developer
> put into a tag as attribute, and to let user agent care about that.

Not really.

The reason the support is there is to allow you to add fields to a
form that would otherwise limit you.  If UserInfoBean had "username"
and "password", the following:

<form name="LogonForm" beanType="com.my.dto.UserInfoBean"/>

... would give you a dyna form with "username" and "password" string
fields.  That said, you can customize each field the way you would a
property configured in struts-config.  Okay, that part's like the tag
attribute support you mentioned.  However, FormDef allows you to add
fields to your form and not be limited by UserInfoBean:

<form name="LogonForm" beanType="com.my.dto.UserInfoBean">
     <field property="selectedButton"/>
</form>

... would give you a dyna form named "LogonForm" with "username",
"password", and "selectedButton" fields.  And with that add'l field,
you can specify type, size, initial as you would in struts-config.

> Michael.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message