You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dale Newfield <Da...@Newfield.org> on 2008/03/24 16:57:21 UTC

Re: [struts] sugestion, reusing actions in different contexts

Mihai Scripca wrote:
> approach 1
> defining 2 actions in struts like this:
> a /view/CerereActEdit.do -> X.class
> b /edit/CerereActEdit.do   -> X.class (same class)
> c /CerereActEdit.do -> X.class (same class)
> 
> but it seems that struts, whatever action i ran it always uses c mapping!

This is because of confusion between the action name/namespace.

Simplest solution:  set struts.enable.SlashesInActionNames to true.

Without that, it's looking for a "view" namespace, or an "edit" 
namespace (and presumably failing to find either).

> i think that the behaviour of struts should be improved to keep track of 
> the context (not losing it on the way)
> and to switch to context only when requested!

Remember, the browser thinks this is just a web page, so if you serve a 
form with a relative action path from the url /app/view/abc.do, it's 
going to submit it as /app/view/newFormAction.do, independent of the 
framework running on the server.  Really this means absolute urls should 
be used almost exclusively (meaning starting with / -- the machine 
should probably be left out).

-Dale

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


Re: [struts] sugestion, reusing actions in different contexts

Posted by Dale Newfield <Da...@Newfield.org>.
Mihai Scripca wrote:
> Dale Newfield wrote:

D'oh--sorry--I was assuming struts2.  My answers are therefore not 
applicable.

-Dale

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


Re: [struts] sugestion, reusing actions in different contexts

Posted by Mihai Scripca <mi...@ucs.ro>.
Dave Newton wrote:
> I'm pretty much lost at this point.
>
>   
> What version of struts are you using?
>   
Im using struts 1.2.7
This is not the behaviour of struts but my desired behaviour!
>   
>> The server should get the request: /app/context/formAction.do, execute the action formAction ,then 
>> should go to struts-config.xml to find the forward:
>> <form path='/formAction.do" ....
>>   <forward ..success... path = /newFormAction.do" />
>>     
then he should forward not to /newFormAction.do but to 
/app/context/newFormAction.do
that is, should keep the current context of the initial executed action
(unless otherwise instructed like this
<forward .... success .... path=/newFormAction.do contextRelative=false
should forward to  /app/newFormAction )
i would like to modify my struts to behave like this but first i thought 
i should share with you so you can tell me what you think
and if theres already a way to do this (except module which is 
unacceptably static)
>
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>   


Re: [struts] sugestion, reusing actions in different contexts

Posted by Dave Newton <ne...@yahoo.com>.
I'm pretty much lost at this point.

What version of struts are you using?

--- Mihai Scripca <mi...@ucs.ro> wrote:
> the server gets the request: /app/view/formAction.do, executes it then 
> goes to struts-config.xml to find the forward and finds:
> <form path='/formAction.do" ....
>   <forward ..success... path = /newFormAction.do" />

Is this like a combination of HTML and configuration file?

Dave


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


Re: [struts] sugestion, reusing actions in different contexts

Posted by Mihai Scripca <mi...@ucs.ro>.
Dale Newfield wrote:
> Mihai Scripca wrote:
>> approach 1
>> defining 2 actions in struts like this:
>> a /view/CerereActEdit.do -> X.class
>> b /edit/CerereActEdit.do   -> X.class (same class)
>> c /CerereActEdit.do -> X.class (same class)
>>
>> but it seems that struts, whatever action i ran it always uses c 
>> mapping!
>
> This is because of confusion between the action name/namespace.
>
> Simplest solution:  set struts.enable.SlashesInActionNames to true.
how is this possible in struts 1? where should i set this?
>
> Without that, it's looking for a "view" namespace, or an "edit" 
> namespace (and presumably failing to find either).
>
>> i think that the behaviour of struts should be improved to keep track 
>> of the context (not losing it on the way)
>> and to switch to context only when requested!
>
> Remember, the browser thinks this is just a web page, so if you serve 
> a form with a relative action path from the url /app/view/abc.do, it's 
> going to submit it as /app/view/newFormAction.do, independent of the 
> framework running on the server.  Really this means absolute urls 
> should be used almost exclusively (meaning starting with / -- the 
> machine should probably be left out).
Yes thats correct but i was reffering to forwards:
the server gets the request: /app/view/formAction.do, executes it then 
goes to struts-config.xml to find the forward and finds:
<form path='/formAction.do" ....
  <forward ..success... path = /newFormAction.do" />
....
then keeps the correct context (/view) (adding it to app context, /app) 
and forms the correct forward like this:

/newFormAction.do  -> would become -> /app .... /view ... /newFormAction.do

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


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