You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Adam Hardy <ah...@cyberspaceroad.com> on 2003/08/06 11:43:29 UTC

Re: Actions Best Practice

Erez Efrati wrote:

> One of the problem I found with 'action=init' method, is that the
> validation is activated automatically for both cases (both init & send),
> and fails of course on the 'init' cause no field is yet in the form. So
> I was forced to configure 'validate=false' and call it manually in the
> Action code.
> 

Option B would be compacter. You can write two action mappings in 
struts-config to distinguish the calls, where one has no validation and 
the other does.

I know some people don't like having extra action mappings in their 
struts-config, but I believe that is what they are there for.


Adam


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


RE: Actions Best Practice

Posted by Erez Efrati <er...@netmedia.net.il>.
First, in my humble opinion, having one Action serving several actions
was the reality welcoming the pink vision of having a small action doing
different thing. Now, combining the two solutions as they are is quite
impossible since they both make use of the same action mapping
'parameter' field. There is however a nice-looking way around it. 
I can write our own version of base ActionForm  override the
validate(mapping, request), ignore the validation only if the
'parameter' is equal to "init" (as a convention, as a rule in the
specific application).
Therefore setting validation=true will be ignored when parameter="init"
and in all other cases will perform the validation.

To use the DispatchAction I would write the same base MyBaseForm, but
this time, it will imitate the DispatchAction and will look if the value
of the named parameter is "init". I think that solves it.

Erez



-----Original Message-----
From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com] 
Sent: Wednesday, August 06, 2003 3:32 PM
To: Struts Users Mailing List
Subject: Re: Actions Best Practice

I thought that was exactly what you were doing!

Erez Efrati wrote:
> The only thing you cannot do is having a mixture of this solution
> (having the action-mapping parameter set to the 'init' or else) and
the
> one of DispatchAction class that keeps all the operation under the
same
> roof (class).
> 
> Erez
> 
> -----Original Message-----
> From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com] 
> Sent: Wednesday, August 06, 2003 3:00 PM
> To: Struts Users Mailing List
> Subject: Re: Actions Best Practice
> 
> That's not necessary. In the action mapping, you can specify the
action 
> parameter with parameter="init" or parameter="send".
> 
> Erez Efrati wrote:
> 
>>Taking your advice, it means that I would have two different action
>>mappings, one for the init step and the second for the actual action
>>(send).
>>But then I will have to write something like 
>><html:link page="/InitForgotPassword.do?action=init"> which is a bit
>>strange to write again the "init", and it is needed cause the
>>ForgotPasswordAction.java needs this 'action' parameter to distinguish
>>between the two. Hmm.. 
>>
>>Erez
>>
>>-----Original Message-----
>>From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com] 
>>Sent: Wednesday, August 06, 2003 11:43 AM
>>To: Struts Users Mailing List
>>Subject: Re: Actions Best Practice
>>
>>Erez Efrati wrote:
>>
>>
>>
>>>One of the problem I found with 'action=init' method, is that the
>>>validation is activated automatically for both cases (both init &
>>
>>send),
>>
>>
>>>and fails of course on the 'init' cause no field is yet in the form.
>>
>>So
>>
>>
>>>I was forced to configure 'validate=false' and call it manually in
the
>>>Action code.
>>>
>>
>>
>>Option B would be compacter. You can write two action mappings in 
>>struts-config to distinguish the calls, where one has no validation
> 
> and 
> 
>>the other does.
>>
>>I know some people don't like having extra action mappings in their 
>>struts-config, but I believe that is what they are there for.
>>
>>
>>Adam
>>
>>
>>---------------------------------------------------------------------
>>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
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> 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
> 
> 


---------------------------------------------------------------------
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: Actions Best Practice

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
I thought that was exactly what you were doing!

Erez Efrati wrote:
> The only thing you cannot do is having a mixture of this solution
> (having the action-mapping parameter set to the 'init' or else) and the
> one of DispatchAction class that keeps all the operation under the same
> roof (class).
> 
> Erez
> 
> -----Original Message-----
> From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com] 
> Sent: Wednesday, August 06, 2003 3:00 PM
> To: Struts Users Mailing List
> Subject: Re: Actions Best Practice
> 
> That's not necessary. In the action mapping, you can specify the action 
> parameter with parameter="init" or parameter="send".
> 
> Erez Efrati wrote:
> 
>>Taking your advice, it means that I would have two different action
>>mappings, one for the init step and the second for the actual action
>>(send).
>>But then I will have to write something like 
>><html:link page="/InitForgotPassword.do?action=init"> which is a bit
>>strange to write again the "init", and it is needed cause the
>>ForgotPasswordAction.java needs this 'action' parameter to distinguish
>>between the two. Hmm.. 
>>
>>Erez
>>
>>-----Original Message-----
>>From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com] 
>>Sent: Wednesday, August 06, 2003 11:43 AM
>>To: Struts Users Mailing List
>>Subject: Re: Actions Best Practice
>>
>>Erez Efrati wrote:
>>
>>
>>
>>>One of the problem I found with 'action=init' method, is that the
>>>validation is activated automatically for both cases (both init &
>>
>>send),
>>
>>
>>>and fails of course on the 'init' cause no field is yet in the form.
>>
>>So
>>
>>
>>>I was forced to configure 'validate=false' and call it manually in the
>>>Action code.
>>>
>>
>>
>>Option B would be compacter. You can write two action mappings in 
>>struts-config to distinguish the calls, where one has no validation
> 
> and 
> 
>>the other does.
>>
>>I know some people don't like having extra action mappings in their 
>>struts-config, but I believe that is what they are there for.
>>
>>
>>Adam
>>
>>
>>---------------------------------------------------------------------
>>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
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> 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
> 
> 


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


RE: Actions Best Practice

Posted by Erez Efrati <er...@netmedia.net.il>.
The only thing you cannot do is having a mixture of this solution
(having the action-mapping parameter set to the 'init' or else) and the
one of DispatchAction class that keeps all the operation under the same
roof (class).

Erez

-----Original Message-----
From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com] 
Sent: Wednesday, August 06, 2003 3:00 PM
To: Struts Users Mailing List
Subject: Re: Actions Best Practice

That's not necessary. In the action mapping, you can specify the action 
parameter with parameter="init" or parameter="send".

Erez Efrati wrote:
> Taking your advice, it means that I would have two different action
> mappings, one for the init step and the second for the actual action
> (send).
> But then I will have to write something like 
> <html:link page="/InitForgotPassword.do?action=init"> which is a bit
> strange to write again the "init", and it is needed cause the
> ForgotPasswordAction.java needs this 'action' parameter to distinguish
> between the two. Hmm.. 
> 
> Erez
> 
> -----Original Message-----
> From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com] 
> Sent: Wednesday, August 06, 2003 11:43 AM
> To: Struts Users Mailing List
> Subject: Re: Actions Best Practice
> 
> Erez Efrati wrote:
> 
> 
>>One of the problem I found with 'action=init' method, is that the
>>validation is activated automatically for both cases (both init &
> 
> send),
> 
>>and fails of course on the 'init' cause no field is yet in the form.
> 
> So
> 
>>I was forced to configure 'validate=false' and call it manually in the
>>Action code.
>>
> 
> 
> Option B would be compacter. You can write two action mappings in 
> struts-config to distinguish the calls, where one has no validation
and 
> the other does.
> 
> I know some people don't like having extra action mappings in their 
> struts-config, but I believe that is what they are there for.
> 
> 
> Adam
> 
> 
> ---------------------------------------------------------------------
> 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
> 
> 


---------------------------------------------------------------------
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: Actions Best Practice

Posted by Erez Efrati <er...@netmedia.net.il>.
You're right it is a good option.
Thanks,
Erez

-----Original Message-----
From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com] 
Sent: Wednesday, August 06, 2003 3:00 PM
To: Struts Users Mailing List
Subject: Re: Actions Best Practice

That's not necessary. In the action mapping, you can specify the action 
parameter with parameter="init" or parameter="send".

Erez Efrati wrote:
> Taking your advice, it means that I would have two different action
> mappings, one for the init step and the second for the actual action
> (send).
> But then I will have to write something like 
> <html:link page="/InitForgotPassword.do?action=init"> which is a bit
> strange to write again the "init", and it is needed cause the
> ForgotPasswordAction.java needs this 'action' parameter to distinguish
> between the two. Hmm.. 
> 
> Erez
> 
> -----Original Message-----
> From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com] 
> Sent: Wednesday, August 06, 2003 11:43 AM
> To: Struts Users Mailing List
> Subject: Re: Actions Best Practice
> 
> Erez Efrati wrote:
> 
> 
>>One of the problem I found with 'action=init' method, is that the
>>validation is activated automatically for both cases (both init &
> 
> send),
> 
>>and fails of course on the 'init' cause no field is yet in the form.
> 
> So
> 
>>I was forced to configure 'validate=false' and call it manually in the
>>Action code.
>>
> 
> 
> Option B would be compacter. You can write two action mappings in 
> struts-config to distinguish the calls, where one has no validation
and 
> the other does.
> 
> I know some people don't like having extra action mappings in their 
> struts-config, but I believe that is what they are there for.
> 
> 
> Adam
> 
> 
> ---------------------------------------------------------------------
> 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
> 
> 


---------------------------------------------------------------------
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: Actions Best Practice

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
That's not necessary. In the action mapping, you can specify the action 
parameter with parameter="init" or parameter="send".

Erez Efrati wrote:
> Taking your advice, it means that I would have two different action
> mappings, one for the init step and the second for the actual action
> (send).
> But then I will have to write something like 
> <html:link page="/InitForgotPassword.do?action=init"> which is a bit
> strange to write again the "init", and it is needed cause the
> ForgotPasswordAction.java needs this 'action' parameter to distinguish
> between the two. Hmm.. 
> 
> Erez
> 
> -----Original Message-----
> From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com] 
> Sent: Wednesday, August 06, 2003 11:43 AM
> To: Struts Users Mailing List
> Subject: Re: Actions Best Practice
> 
> Erez Efrati wrote:
> 
> 
>>One of the problem I found with 'action=init' method, is that the
>>validation is activated automatically for both cases (both init &
> 
> send),
> 
>>and fails of course on the 'init' cause no field is yet in the form.
> 
> So
> 
>>I was forced to configure 'validate=false' and call it manually in the
>>Action code.
>>
> 
> 
> Option B would be compacter. You can write two action mappings in 
> struts-config to distinguish the calls, where one has no validation and 
> the other does.
> 
> I know some people don't like having extra action mappings in their 
> struts-config, but I believe that is what they are there for.
> 
> 
> Adam
> 
> 
> ---------------------------------------------------------------------
> 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
> 
> 


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


RE: Actions Best Practice

Posted by Erez Efrati <er...@netmedia.net.il>.
Taking your advice, it means that I would have two different action
mappings, one for the init step and the second for the actual action
(send).
But then I will have to write something like 
<html:link page="/InitForgotPassword.do?action=init"> which is a bit
strange to write again the "init", and it is needed cause the
ForgotPasswordAction.java needs this 'action' parameter to distinguish
between the two. Hmm.. 

Erez

-----Original Message-----
From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com] 
Sent: Wednesday, August 06, 2003 11:43 AM
To: Struts Users Mailing List
Subject: Re: Actions Best Practice

Erez Efrati wrote:

> One of the problem I found with 'action=init' method, is that the
> validation is activated automatically for both cases (both init &
send),
> and fails of course on the 'init' cause no field is yet in the form.
So
> I was forced to configure 'validate=false' and call it manually in the
> Action code.
> 

Option B would be compacter. You can write two action mappings in 
struts-config to distinguish the calls, where one has no validation and 
the other does.

I know some people don't like having extra action mappings in their 
struts-config, but I believe that is what they are there for.


Adam


---------------------------------------------------------------------
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