You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Sachin <sa...@patni.com> on 2002/04/09 09:47:01 UTC

Is FormBean mandatory???

Hi

Action class interacts with a model,where business logic resides.In my
project i have designed the model in such a way that there is mapping of a
table with a Value Object.So the Value Object will have a setter & getter
methods.(for eg. if there are 5 columns in a table,then Value object will
have 5 setter& getter methods ).

In action class i call some business methods which returns Value Object
.Then i put the Value Object in the session and retrieve the same in jsp
page with the help of iterate tag.
In this scenario if i donot use form bean,then also i will be able to
proceed in my jsp page.

Could anyone explain the pros & cons of not using form beans in my project
and are there any performance issues in this context??


Thanks & Regards,
Sachin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Is FormBean mandatory???

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 9 Apr 2002, Konstantin Priblouda wrote:

> Date: Tue, 9 Apr 2002 08:15:03 -0700 (PDT)
> From: Konstantin Priblouda <kp...@yahoo.com>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: Struts Developers List <st...@jakarta.apache.org>,
>      matt@raibledesigns.com
> Subject: RE: Is FormBean mandatory???
>
> --- Matt Raible <ma...@raibledesigns.com> wrote:
> > Web forms can only handle Strings and booleans - so
> > if your value
> > objects have Dates or Integers, get ready for some
> > fun!
>
> Integers are completely OK, floats depend on sanity of
> web users. ( imagine some bank clerk who is used
> to enter dots to separate 000... )
>

Using int or Integer properties in a form bean misses the whole reason for
its existence -- to reproduce the user's input in case they made a
mistake.

Consider that you've got an input field called "size", which (in your
business logic should really be an integer).  Assume for a moment that you
try to use an "int" or "Integer" property in the form bean, so that the
conversion happens as the form bean properties get populated.  Now, assume
that the user mis-types "1a3" instead of "123" into this field.

Using an int field, you get an ugly exception when the form bean
properties are populated -- and any properties that haven't been populated
yet have errors.

Using a String field, you get the ability to validate the input, produce a
nice error message, and (most importantly to meet users expectations)
redisplay the input field with the incorrect value that he or she did
enter, so that they can fix it.  Any user who has ever used a GUI app is
going to expect this behavior in a web app.

The form bean is part of the VIEW layer in an MVC architecture, not the
MODEL layer.  It's sole purpose in life is to represent the server-side
state of the last set of inputs to a particular form (even if they are not
valid).  Conversion into value objects (or directly to the database,
depending on how you have your business logic set up) should be done by a
"save" type action, after the form fields have been validated.

> IMHO, struts shall behave more beany/reflection- with
> possibility to set property editors for a bean.
>
> ( now I'm doing blasphemy: like webwork does :) )
>

It turns out that property editors have technical problems that have been
discussed before (check the mail archives for details).  However, you
should check out the recent changes to ConvertUtils in the
commons-beanutils package), which let you plug in your own String->Object
converters.  This is available in the Struts 1.1 beta, and will also be
available in the 1.1 final release.

> regards,
>
>
> =====
> Konstantin Priblouda ( ko5tik )    Freelance Software developer
> < http://www.pribluda.de > < play java games -> http://www.yook.de >
> < render charts online -> http://www.pribluda.de/povray/ >
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Is FormBean mandatory???

Posted by Konstantin Priblouda <kp...@yahoo.com>.
--- Matt Raible <ma...@raibledesigns.com> wrote:
> Web forms can only handle Strings and booleans - so
> if your value
> objects have Dates or Integers, get ready for some
> fun!

Integers are completely OK, floats depend on sanity of
web users. ( imagine some bank clerk who is used
to enter dots to separate 000... )

IMHO, struts shall behave more beany/reflection- with 
possibility to set property editors for a bean. 

( now I'm doing blasphemy: like webwork does :) )

regards,


=====
Konstantin Priblouda ( ko5tik )    Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >

__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Is FormBean mandatory???

Posted by Matt Raible <ma...@raibledesigns.com>.
Web forms can only handle Strings and booleans - so if your value
objects have Dates or Integers, get ready for some fun!



> -----Original Message-----
> From: Sachin [mailto:sachin.mapara@patni.com]
> Sent: Tuesday, April 09, 2002 1:47 AM
> To: struts-dev@jakarta.apache.org
> Subject: Is FormBean mandatory???
> 
> Hi
> 
> Action class interacts with a model,where business logic resides.In my
> project i have designed the model in such a way that there is mapping
of a
> table with a Value Object.So the Value Object will have a setter &
getter
> methods.(for eg. if there are 5 columns in a table,then Value object
will
> have 5 setter& getter methods ).
> 
> In action class i call some business methods which returns Value
Object
> .Then i put the Value Object in the session and retrieve the same in
jsp
> page with the help of iterate tag.
> In this scenario if i donot use form bean,then also i will be able to
> proceed in my jsp page.
> 
> Could anyone explain the pros & cons of not using form beans in my
project
> and are there any performance issues in this context??
> 
> 
> Thanks & Regards,
> Sachin
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:struts-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-dev-
> help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>