You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Curley, John" <Jo...@NielsenMedia.com> on 2003/03/04 14:51:39 UTC

Form Beans: Design Question

Please excuse the simple question (I am new to Struts):

When is it appropriate to use form beans for an action?

The reason why I ask is because you can obtain information from a request
via the information sent by the HTTP/Post/Get.  If I have a bunch of widgets
in a form I can just obtain the info in the action this way:

request.getParameter("widgetName")

I have a fairly good understanding of how form beans work, but I'm just
wondering in what type(s) of situation(s) these would be applied.

Thanks for your help.

John Curley


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


Re: Form Beans: Design Question

Posted by Nicolas De Loof <ni...@cgey.com>.
Your right, formbean "just" get request parameter for you. But they
are doing this too:

- allow syntax validation, programatically or by rules (via
validator.xml)
- allow "dotted" and indexed syntax (like  "property1.property2[3]"),
and so a realy objet-oriented formbean design
- can be dynabeans (so you don't need to create javabeans)

Nico.

>
> Please excuse the simple question (I am new to Struts):
>
> When is it appropriate to use form beans for an action?
>
> The reason why I ask is because you can obtain information from a
request
> via the information sent by the HTTP/Post/Get.  If I have a bunch of
widgets
> in a form I can just obtain the info in the action this way:
>
> request.getParameter("widgetName")
>
> I have a fairly good understanding of how form beans work, but I'm
just
> wondering in what type(s) of situation(s) these would be applied.
>
> Thanks for your help.
>
> John Curley
>
>
> --------------------------------------------------------------------
-
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Re: Form Beans: Design Question

Posted by Rick Reumann <ma...@reumann.net>.
On Tue, 4 Mar 2003 08:51:39 -0500 
"Curley, John" <Jo...@NielsenMedia.com> wrote:

  
> The reason why I ask is because you can obtain information from a
> request via the information sent by the HTTP/Post/Get.  If I have a
> bunch of widgets in a form I can just obtain the info in the action
> this way:
> 
> request.getParameter("widgetName")

Another reason that I didn't see mentioned is: often times you usually
need to the information from a form into the business layer. You don't
really want to pass the servlet stuff (request,etc) over into the other
layer so usually you transfer the request information into a business
object (often called a Data Transfer Object or Value Object). Using
BeanUtils makes it very easy to copy all of your form bean parameters in
one fell swoop into this business object:

BeanUtils.copyProperties( businessObject, formBean );

So having all of your request information in a formBean is usually very
convenient and it makes it very easy to hand off the information to the
business logic of your application.


-- 
Rick Reumann

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