You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by rmchiriac <rm...@mail.md> on 2004/04/14 13:10:17 UTC

when not to use an ActionForm

Hi,

i've got a pretty simple action that takes a couple of params, does some simple parameter validation (in case there are any problems the user is redirected to an error page) and has no html form associated with it (it's called using a GET method from an UI test)... would using an ActionForm in this case be necessary? or using request.getParameter() in action will be enough? 

thanks
r

___________________________________________
Get your free mail box @ http://www.mail.md



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


Re: when not to use an ActionForm

Posted by Oswald Campesato <oc...@yahoo.com>.
Hello, Martin/Andy:
 
I'd like to suggest using JSTL for this type of scenario.  You can find a 
nice explanation at the following URL (my compliments to its author):
 
http://jakarta.apache.org/struts/faqs/indexedprops.html

Regards,
 
Oswald
 
Note:  I also downloaded the tag-libs project, because the solution outlined 
in the preceding URL requires both jstl.jar and standard.jar, which contains
org/apache/taglibs/standard/lang/support/ExpressionManager.class
 

Martin Cooper <ma...@apache.org> wrote:

"Andy Engle" wrote in message
news:20040414225317.90035.qmail@web41504.mail.yahoo.com...
> Vijay.Kukreja@siriuscom.com wrote:
>
> > Richard,
> > Its not necessary to use ActionForm, but it is always better to use
> > one(its my philosophy). But yes it will work the way you are doing
> > it. But i rather prefer a ActionForm which can also help in future
> > for any validation or in future if decided to add more attributes to
> > the form..
>
> With this discussion in mind, I am wondering if there is any way I can
> use an ActionForm in the following scenario: I would like to have a
> list of fields, dynamically created, with names that have been
> dynamically created along with those fields. So, for example, I would
> have a series of input fields like this:
>
>  [input] 
>  [input] 
>  [input] 
>
> The "field_" part of the name value will stay, but the number will
> change. With these field name values being so dynamic, is there any
> trick I can use to feed all this into an ActionForm? I don't think
> there is, unless I am missing something...

I don't believe it can be done with the fields named like that, but there is
a trick you might be able to use. ;-)

1) In the  [input]  elements, use names of the form "dynaFields.field_1", etc.
The name isn't important, but the dot is.
2) Create a corresponding Map property in your form bean (i.e. a property
named "dynaFields" in this example).

When your action form is populated, you will end up with the "dynaFields"
map containing key/value pairs corresponding to the name/value pairs from
your  [input]  elements.

--
Martin Cooper


>
>
> Thanks,
> Andy




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

		
---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th

RE: when not to use an ActionForm

Posted by Daniel Joshua <da...@gridnode.com>.
Great idea... make use of the nested property!

But what would the advantage be of using this "Map" as compared to the
request.getParameters()'s "Map"?

All I can see that it only would be useful if you did some validation in
your ActionForm on the "Map", any other uses?


Regards,
Daniel


-----Original Message-----
From: news [mailto:news@sea.gmane.org]On Behalf Of Martin Cooper
Sent: Thursday, 15 April, 2004 7:10 AM
To: user@struts.apache.org
Subject: Re: when not to use an ActionForm



I don't believe it can be done with the fields named like that, but there is
a trick you might be able to use. ;-)

1) In the <input> elements, use names of the form "dynaFields.field_1", etc.
The name isn't important, but the dot is.
2) Create a corresponding Map property in your form bean (i.e. a property
named "dynaFields" in this example).

When your action form is populated, you will end up with the "dynaFields"
map containing key/value pairs corresponding to the name/value pairs from
your <input> elements.

--
Martin Cooper


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


Re: when not to use an ActionForm

Posted by Martin Cooper <ma...@apache.org>.
"Andy Engle" <st...@andyengle.com> wrote in message
news:20040414225317.90035.qmail@web41504.mail.yahoo.com...
> Vijay.Kukreja@siriuscom.com wrote:
>
> > Richard,
> > Its not necessary to use ActionForm, but it is always better to use
> > one(its my philosophy). But yes it will work the way you are doing
> > it. But i rather prefer a ActionForm which can also help in future
> > for any validation or in future if decided to add more attributes to
> > the form..
>
> With this discussion in mind, I am wondering if there is any way I can
> use an ActionForm in the following scenario: I would like to have a
> list of fields, dynamically created, with names that have been
> dynamically created along with those fields.  So, for example, I would
> have a series of input fields like this:
>
> <input type="text" name="field_1">
> <input type="text" name="field_2">
> <input type="text" name="field_3">
>
> The "field_" part of the name value will stay, but the number will
> change.  With these field name values being so dynamic, is there any
> trick I can use to feed all this into an ActionForm?  I don't think
> there is, unless I am missing something...

I don't believe it can be done with the fields named like that, but there is
a trick you might be able to use. ;-)

1) In the <input> elements, use names of the form "dynaFields.field_1", etc.
The name isn't important, but the dot is.
2) Create a corresponding Map property in your form bean (i.e. a property
named "dynaFields" in this example).

When your action form is populated, you will end up with the "dynaFields"
map containing key/value pairs corresponding to the name/value pairs from
your <input> elements.

--
Martin Cooper


>
>
> Thanks,
> Andy




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


Re: when not to use an ActionForm

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
You could use the "Lazy" stuff I wrote.

I only have "validator" versions of Lazy Forms - you could use them and set
validate="false" on the Action in struts-config.xml or put a LazyDynaBean in
your action form.

http://www.niallp.pwp.blueyonder.co.uk

Niall


----- Original Message ----- 
From: "Andy Engle" <st...@andyengle.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Wednesday, April 14, 2004 11:53 PM
Subject: Re: when not to use an ActionForm


> Vijay.Kukreja@siriuscom.com wrote:
>
> > Richard,
> > Its not necessary to use ActionForm, but it is always better to use
> > one(its my philosophy). But yes it will work the way you are doing
> > it. But i rather prefer a ActionForm which can also help in future
> > for any validation or in future if decided to add more attributes to
> > the form..
>
> With this discussion in mind, I am wondering if there is any way I can
> use an ActionForm in the following scenario: I would like to have a
> list of fields, dynamically created, with names that have been
> dynamically created along with those fields.  So, for example, I would
> have a series of input fields like this:
>
> <input type="text" name="field_1">
> <input type="text" name="field_2">
> <input type="text" name="field_3">
>
> The "field_" part of the name value will stay, but the number will
> change.  With these field name values being so dynamic, is there any
> trick I can use to feed all this into an ActionForm?  I don't think
> there is, unless I am missing something...
>
>
> Thanks,
> Andy
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



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


Re: when not to use an ActionForm

Posted by Andy Engle <st...@andyengle.com>.
Vijay.Kukreja@siriuscom.com wrote:

> Richard,
> Its not necessary to use ActionForm, but it is always better to use 
> one(its my philosophy). But yes it will work the way you are doing
> it. But i rather prefer a ActionForm which can also help in future
> for any validation or in future if decided to add more attributes to
> the form..

With this discussion in mind, I am wondering if there is any way I can
use an ActionForm in the following scenario: I would like to have a
list of fields, dynamically created, with names that have been
dynamically created along with those fields.  So, for example, I would
have a series of input fields like this:

<input type="text" name="field_1">
<input type="text" name="field_2">
<input type="text" name="field_3">

The "field_" part of the name value will stay, but the number will
change.  With these field name values being so dynamic, is there any
trick I can use to feed all this into an ActionForm?  I don't think
there is, unless I am missing something...


Thanks,
Andy


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


Re: when not to use an ActionForm

Posted by Vi...@siriuscom.com.
Richard,
Its not necessary to use ActionForm, but it is always better to use 
one(its my philosophy). But yes it will work the way you are doing it. But 
i rather prefer a ActionForm which can also help in future for any 
validation or in future if decided to add more attributes to the form..

Vijay.