RE: error checking in Action

2002-10-29 Thread Mark Silva
yes i agree.  

my error checking is going into a buisness level helper class (instead of the form) 
because it is so complex.  it onvolves going into the database, and making sure there 
are a minimum number of an item left, before a user can make changes to it.  it also 
needs to check various other attributes from the db.  i thought that this was too 
cumbersome to be in the form.

andrew mentioned some ways to forward back to the form with an error in 1.1.  i am 
using 1.0, will these techniques still work?  are there any other suggestions on how 
to do this in 1.0?  unfortunately i need to stick to 1.0, so suggestion to upgrade are 
not going to help much :-)

thanks,
-mark


-Original Message-
From: David Graham [mailto:dgraham1980@;hotmail.com]
Sent: Monday, October 28, 2002 10:38 PM
To: [EMAIL PROTECTED]
Subject: Re: error checking in Action


Nice restatement Rob.  That's exactly how I see the validation working.  I 
know I'm in trouble when my action class gets too big :-).

David



>From: Rob Leland <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: Struts Users Mailing List <[EMAIL PROTECTED]>
>Subject: Re: error checking in Action
>Date: Tue, 29 Oct 2002 00:14:55 -0500
>
>David Graham wrote:
>
>>Why do you "need" to move error checking into an action?  Why not just
>>let the form bean do it's job and validate itself?  Have you looked at
>>using the validator?  Validation belongs in the form bean; actions' main
>>job is to direct traffic and execute business layer methods.
>>
>>David
>>
>
>Agreed,
>For Generic type of validation the ActionForm is an appropiate
>place to do validation. To restate what David said, the ActionForm
>is designed to be passive, and have values info it needs passed
>to it. It should definately not make method calls to other Business Logic.
>
>To add to that,Any complex validation would take place in the Business 
>Logic, with the Action being the go between loading and unloading the
>ActionForm and calling validation methods in the Business Logic.
>
>
>-Rob
>
>
>--
>To unsubscribe, e-mail:   
><mailto:struts-user-unsubscribe@;jakarta.apache.org>
>For additional commands, e-mail: 
><mailto:struts-user-help@;jakarta.apache.org>


_
Get faster connections -- switch to MSN Internet Access! 
http://resourcecenter.msn.com/access/plans/default.asp


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


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




Re: error checking in Action

2002-10-28 Thread David Graham
Nice restatement Rob.  That's exactly how I see the validation working.  I 
know I'm in trouble when my action class gets too big :-).

David



From: Rob Leland <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: Struts Users Mailing List <[EMAIL PROTECTED]>
Subject: Re: error checking in Action
Date: Tue, 29 Oct 2002 00:14:55 -0500

David Graham wrote:


Why do you "need" to move error checking into an action?  Why not just
let the form bean do it's job and validate itself?  Have you looked at
using the validator?  Validation belongs in the form bean; actions' main
job is to direct traffic and execute business layer methods.

David



Agreed,
For Generic type of validation the ActionForm is an appropiate
place to do validation. To restate what David said, the ActionForm
is designed to be passive, and have values info it needs passed
to it. It should definately not make method calls to other Business Logic.

To add to that,Any complex validation would take place in the Business 
Logic, with the Action being the go between loading and unloading the
ActionForm and calling validation methods in the Business Logic.


-Rob


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


_
Get faster connections -- switch to MSN Internet Access! 
http://resourcecenter.msn.com/access/plans/default.asp


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



Re: error checking in Action

2002-10-28 Thread Rob Leland
David Graham wrote:


Why do you "need" to move error checking into an action?  Why not just
let the form bean do it's job and validate itself?  Have you looked at
using the validator?  Validation belongs in the form bean; actions' main
job is to direct traffic and execute business layer methods.

David



Agreed,
For Generic type of validation the ActionForm is an appropiate
place to do validation. To restate what David said, the ActionForm
is designed to be passive, and have values info it needs passed
to it. It should definately not make method calls to other Business Logic.

To add to that,Any complex validation would take place in the Business 
Logic, with the Action being the go between loading and unloading the
ActionForm and calling validation methods in the Business Logic.


-Rob


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 



RE: error checking in Action

2002-10-28 Thread Andrew Hill
I do all my validation in the action too - I need a lot of info from the
b-tier about such things as which fields are mandatory when, etc... and it
proved inconvienient (still quite possible - just required some ugly
contortions - especially given some of the evil things Im doing in the
RequestProcessor which you would rather not know about ;-> ) to do it in the
form. I rather like to keep my forms stupid too (ie: just a simple data
structure with getters and setters.) and put code that does the work of
validating, directing traffic, and calling the business objects together in
the same class. Not so OOPy, but I find it saves time and makes it easier to
locate and work on things.

In fact most of my crud actions are subclasses of a common abstract
(dispatch) action , which has an abstract validation method it calls and
then returns the user to the form complete with actionErrors as normal if
the validation fails. (Im cheating a bit , in that if my save method fails
due to validation errors, rather than doing a forward back to the input
(which is in fact that same action (Im not using JSPs but rather a homebaked
rendering technique based around DOM - which needs an action to set up the
renderers for the view)) I simply make a direct call to my update method...)

If you are validating in the action , you can get the relative path(*) to
return to if validation fails from mapping.getInput() which returns a
string - the contents of which are the value of the input attribute in your
action mapping in struts config. You could probably build an ActionFrward
out of this and return it from the action. Since you would be forwarding
(ie: make redirect=false) all the stuff in your request context will be
preserved and sent back to the input - including the ActionForm populated
from the request.

The code struts uses to call validation in your actionForm and return to the
input if it fails may (in 1.1) be found in the processValidate() method of
the RequestProcessor.



(*) Struts 1.1b2 appears to allow the input to be the name of a forward
instead of a path now, but I havent had time to examine this new
functionality yet.


-Original Message-
From: David Graham [mailto:dgraham1980@;hotmail.com]
Sent: Tuesday, October 29, 2002 09:05
To: [EMAIL PROTECTED]
Subject: Re: error checking in Action


Why do you "need" to move error checking into an action?  Why not just let
the form bean do it's job and validate itself?  Have you looked at using the
validator?  Validation belongs in the form bean; actions' main job is to
direct traffic and execute business layer methods.

David






>From: "Mark Silva" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>Subject: error checking in Action
>Date: Mon, 28 Oct 2002 16:54:39 -0800
>
>I need to do some extensive error checking, and need to move this into an
>action class.
>
>my question is when i identify an action, how i forward back to the
>previous page (the same way a form class would).  is there a method to take
>care of this?  or do i need to setup all the passed values in the request
>again and do an ActionForward to the appropriate page?
>
>thanks,
>mark
>
>
>
>--
>To unsubscribe, e-mail:
><mailto:struts-user-unsubscribe@;jakarta.apache.org>
>For additional commands, e-mail:
><mailto:struts-user-help@;jakarta.apache.org>


_
Unlimited Internet access -- and 2 months free!  Try MSN.
http://resourcecenter.msn.com/access/plans/2monthsfree.asp


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


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




Re: error checking in Action

2002-10-28 Thread David Graham
Why do you "need" to move error checking into an action?  Why not just let 
the form bean do it's job and validate itself?  Have you looked at using the 
validator?  Validation belongs in the form bean; actions' main job is to 
direct traffic and execute business layer methods.

David






From: "Mark Silva" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Subject: error checking in Action
Date: Mon, 28 Oct 2002 16:54:39 -0800

I need to do some extensive error checking, and need to move this into an 
action class.

my question is when i identify an action, how i forward back to the 
previous page (the same way a form class would).  is there a method to take 
care of this?  or do i need to setup all the passed values in the request 
again and do an ActionForward to the appropriate page?

thanks,
mark



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


_
Unlimited Internet access -- and 2 months free!  Try MSN. 
http://resourcecenter.msn.com/access/plans/2monthsfree.asp


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



error checking in Action

2002-10-28 Thread Mark Silva
I need to do some extensive error checking, and need to move this into an action class.

my question is when i identify an action, how i forward back to the previous page (the 
same way a form class would).  is there a method to take care of this?  or do i need 
to setup all the passed values in the request again and do an ActionForward to the 
appropriate page?

thanks,
mark



--
To unsubscribe, e-mail:   
For additional commands, e-mail: