You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alok Rajkumar Gupta <al...@wipro.com> on 2003/02/10 09:02:05 UTC
Threading issues
In case of Action Objects what are the threading issues expected.
Regards
Alok Gupta
-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org]
Sent: Monday, February 10, 2003 12:56 PM
To: Kashinath
Cc: Struts Users Mailing List
Subject: Re: Model and Controller Components
On Mon, 10 Feb 2003, Kashinath wrote:
> Date: Mon, 10 Feb 2003 11:25:45 -0000
> From: Kashinath <ka...@visualsoft-tech.com>
> To: Craig R. McClanahan <cr...@apache.org>,
> Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: Model and Controller Components
>
> thanks a lot Craig for your information.
> Craig what is your view on ActionForm as Model.
> Is it a model?
Absolutely *not*. As the original creator of Struts, who designed it
the way it is for a reason, I hope you will take this statement
seriously.
ActionForm is part of the view tier -- it's only purpose in life is to
represent the server-side state of the current values that the user has
typed on an input form. For example, consider a field that (in your
database) is an integer. What should happen if the user types "1a3"
instead of "123" into the corresponding text field?
* The validation checking should catch this problem and
create an appropriate error message.
* The input page should be redisplayed (along with the
error messages, *including* the "1a3" value that the
user originally entered. That is the way GUI programs
work, and that is what webapp users expect as well.
In order to accomplish this, Struts strongly recommends that the
JavaBean property for an integer field in your ActionForm bean should be
a String
-- that's the only way you can reproduce exactly what the user
originally typed if he or she makes a mistake.
In your Action that processes the input form, after validations have
proven that you can successfully convert this String into an integer,
*that* is where you should convert to native datatypes in a value object
(or whatever other mechanism you are using to communicate with your
business logic). Investigate the BeanUtils.copyProperties() method for
painless copy-and-convert functionality of all the properties in a form
bean into corresponding native properties in a value object.
For lots and lots more information about this topic, you can search the
mailing list archives for discussions of ActionForm and the three tiers,
or read any of the recent books about Struts.
If you find documentation in Struts that talks about form beans being
model objects, please point them out specifically -- that documentation
is wrong, and needs to be corrected.
> kasi
Craig McClanahan
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
**************************Disclaimer************************************
Information contained in this E-MAIL being proprietary to Wipro Limited is
'privileged' and 'confidential' and intended for use only by the individual
or entity to which it is addressed. You are notified that any use, copying
or dissemination of the information contained in the E-MAIL in any manner
whatsoever is strictly prohibited.
***************************************************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Threading issues
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Mon, 10 Feb 2003, Alok Rajkumar Gupta wrote:
> Date: Mon, 10 Feb 2003 13:32:05 +0530
> From: Alok Rajkumar Gupta <al...@wipro.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Threading issues
>
>
> In case of Action Objects what are the threading issues expected.
>
Action objects have the same thread behavior issues as servlets -- there
will be a single instance (per Action definition in struts-config.xml),
which will be accessed via multiple threads at the same time.
In general, that means "do not store per-request state in class instance
variables in an Action." It's fine to use instance variables for shared
information; just remember that it is shared.
> Regards
> Alok Gupta
Craig
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org