You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paul Benedict <pb...@apache.org> on 2012/08/05 07:23:28 UTC

S2 support for index action?

I see that <default-action-ref> allows an action to execute if the
user's path cannot be found. This is almost what I want but not quite.
I would like to have an IMPLICIT "index" action for my packages. My
configuration does not use any suffix -- everything goes to Struts
(i.e., /*) -- so this feature is sensible for my configuration.

Paul

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


Re: S2 support for index action?

Posted by Paul Benedict <pb...@apache.org>.
I am asking to find out if such ability exists today. If not, I will
be submitting a patch :-)

On Mon, Aug 20, 2012 at 7:26 PM, Martin Gainty <mg...@hotmail.com> wrote:
>
>
>
>
>> Date: Mon, 20 Aug 2012 14:45:37 -0500
>> Subject: Re: S2 support for index action?
>> From: pbenedict@apache.org
>> To: user@struts.apache.org
>>
>> Are you familiar with index actions in HTTP servers? It's the page
>> that loads when a directory is specified. It's the default when no
>> specific resource is requested. That's different than the "default
>> action" in S2 which runs if no suitable action can be found.
>>
>> Pretend there is a default package called "checkout" with "viewCart"
>> set to the default action. Here are some example actions in that
>> package:
>> /checkout/addToCart.action = Adds item to cart
>> /checkout/viewCart.action = Views items in cart
>> /checkout/ = runs default action
>> /checkout/zzzzzz = runs default action too
>> /checkout/qwerty = runs default action too
>>
>> As you can see, S2 interprets the default action to mean "I can't find
>> anything so let's execute the default." I am saying, we should allow a
>> more narrow configuration that says run the default action only if NO
>> specific resource in the package is being requested.
>>
>> Paul
>
> MG>org.apache.struts2.dispatcher.mapper.DefaultActionMapper
> MG>protected void parseNameAndNamespace(String uri, ActionMapping mapping, ConfigurationManager configManager)
> MG>you're going to have to negotiate around struts.mapper.alwaysSelectFullNamespace when the value is true the default when no namespaces are found is set to root
> MG>    // Still none found, use root namespace if found
> MG>       if (rootAvailable && "".equals(namespace)) {
> MG>               namespace = "/";
> MG>           }
>
>> On Mon, Aug 20, 2012 at 2:39 PM, Lukasz Lenart <lu...@apache.org> wrote:
>> > 2012/8/20 Paul Benedict <pb...@apache.org>:
>> >> Lukasz,
>> >>
>> >> The docs say <default-action-ref/> runs when any URI can't be found in
>> >> the package. I don't want much liberty. Just when the package matches
>> >> the URI exactly, have a default action. In regards to configuration,
>> >> this might be as easy as adding a new attribute to that element. What
>> >> do you think?
>> >
>> > Still don't get it :/ Maybe some example would help...
>> >
>> >
>> > Regards
>> > --
>> > Łukasz
>> > + 48 606 323 122 http://www.lenart.org.pl/
>> >
>> > ---------------------------------------------------------------------
>> > 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
>>
>

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


RE: S2 support for index action?

Posted by Martin Gainty <mg...@hotmail.com>.



> Date: Mon, 20 Aug 2012 14:45:37 -0500
> Subject: Re: S2 support for index action?
> From: pbenedict@apache.org
> To: user@struts.apache.org
> 
> Are you familiar with index actions in HTTP servers? It's the page
> that loads when a directory is specified. It's the default when no
> specific resource is requested. That's different than the "default
> action" in S2 which runs if no suitable action can be found.
> 
> Pretend there is a default package called "checkout" with "viewCart"
> set to the default action. Here are some example actions in that
> package:
> /checkout/addToCart.action = Adds item to cart
> /checkout/viewCart.action = Views items in cart
> /checkout/ = runs default action
> /checkout/zzzzzz = runs default action too
> /checkout/qwerty = runs default action too
> 
> As you can see, S2 interprets the default action to mean "I can't find
> anything so let's execute the default." I am saying, we should allow a
> more narrow configuration that says run the default action only if NO
> specific resource in the package is being requested.
> 
> Paul

MG>org.apache.struts2.dispatcher.mapper.DefaultActionMapper
MG>protected void parseNameAndNamespace(String uri, ActionMapping mapping, ConfigurationManager configManager) 
MG>you're going to have to negotiate around struts.mapper.alwaysSelectFullNamespace when the value is true the default when no namespaces are found is set to root
MG>    // Still none found, use root namespace if found
MG>       if (rootAvailable && "".equals(namespace)) {
MG>               namespace = "/";
MG>           }

> On Mon, Aug 20, 2012 at 2:39 PM, Lukasz Lenart <lu...@apache.org> wrote:
> > 2012/8/20 Paul Benedict <pb...@apache.org>:
> >> Lukasz,
> >>
> >> The docs say <default-action-ref/> runs when any URI can't be found in
> >> the package. I don't want much liberty. Just when the package matches
> >> the URI exactly, have a default action. In regards to configuration,
> >> this might be as easy as adding a new attribute to that element. What
> >> do you think?
> >
> > Still don't get it :/ Maybe some example would help...
> >
> >
> > Regards
> > --
> > Łukasz
> > + 48 606 323 122 http://www.lenart.org.pl/
> >
> > ---------------------------------------------------------------------
> > 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
> 
 		 	   		  

Re: S2 support for index action?

Posted by Lukasz Lenart <lu...@apache.org>.
2012/8/21 Rene Gielen <gi...@it-neering.net>:
> I think I see the use case - while accessing /cart/ should be a valid request to the cart topic landing page (index), default action might map to a default "unknown URI" page, which has say a humble error message and some suggestions what URIs the user would want to access.

Hm... you're right, index action and default action can be treated as
two different use cases.

@Paul do you have a patch for that already ?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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


Re: S2 support for index action?

Posted by Rene Gielen <gi...@it-neering.net>.
I think I see the use case - while accessing /cart/ should be a valid request to the cart topic landing page (index), default action might map to a default "unknown URI" page, which has say a humble error message and some suggestions what URIs the user would want to access.
-- 
Sent from my mobile phone



Lukasz Lenart <lu...@apache.org> schrieb:

2012/8/20 Paul Benedict <pb...@apache.org>:
> Are you familiar with index actions in HTTP servers? It's the page
> that loads when a directory is specified. It's the default when no
> specific resource is requested. That's different than the "default
> action" in S2 which runs if no suitable action can be found.
>
> Pretend there is a default package called "checkout" with "viewCart"
> set to the default action. Here are some example actions in that
> package:
> /checkout/addToCart.action = Adds item to cart
> /checkout/viewCart.action = Views items in cart
> /checkout/ = runs default action
> /checkout/zzzzzz = runs default action too
> /checkout/qwerty = runs default action too
>
> As you can see, S2 interprets the default action to mean "I can't find
> anything so let's execute the default." I am saying, we should allow a
> more narrow configuration that says run the default action only if NO
> specific resource in the package is being requested.

But isn't the same as default action per package ? Where you can
specify the index action:

<package name="default" namespace="/" extends="struts-default">

<default-action-ref name="index" />

<action name="index">
<result>index.jsp</result>
</action>

</package>

Or would you have a more sophisticated mechanism which will
automagically discover index action instead of specifying default
action for each package ?

The case is that there can be more than one class used to implement
actions for given namespace.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

_____________________________________________

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


Re: S2 support for index action?

Posted by Lukasz Lenart <lu...@apache.org>.
2012/8/20 Paul Benedict <pb...@apache.org>:
> Are you familiar with index actions in HTTP servers? It's the page
> that loads when a directory is specified. It's the default when no
> specific resource is requested. That's different than the "default
> action" in S2 which runs if no suitable action can be found.
>
> Pretend there is a default package called "checkout" with "viewCart"
> set to the default action. Here are some example actions in that
> package:
> /checkout/addToCart.action = Adds item to cart
> /checkout/viewCart.action = Views items in cart
> /checkout/ = runs default action
> /checkout/zzzzzz = runs default action too
> /checkout/qwerty = runs default action too
>
> As you can see, S2 interprets the default action to mean "I can't find
> anything so let's execute the default." I am saying, we should allow a
> more narrow configuration that says run the default action only if NO
> specific resource in the package is being requested.

But isn't the same as default action per package ? Where you can
specify the index action:

<package name="default" namespace="/" extends="struts-default">

        <default-action-ref name="index" />

        <action name="index">
            <result>index.jsp</result>
        </action>

</package>

Or would you have a more sophisticated mechanism which will
automagically discover index action instead of specifying default
action for each package ?

The case is that there can be more than one class used to implement
actions for given namespace.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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


Re: S2 support for index action?

Posted by Paul Benedict <pb...@apache.org>.
Are you familiar with index actions in HTTP servers? It's the page
that loads when a directory is specified. It's the default when no
specific resource is requested. That's different than the "default
action" in S2 which runs if no suitable action can be found.

Pretend there is a default package called "checkout" with "viewCart"
set to the default action. Here are some example actions in that
package:
/checkout/addToCart.action = Adds item to cart
/checkout/viewCart.action = Views items in cart
/checkout/ = runs default action
/checkout/zzzzzz = runs default action too
/checkout/qwerty = runs default action too

As you can see, S2 interprets the default action to mean "I can't find
anything so let's execute the default." I am saying, we should allow a
more narrow configuration that says run the default action only if NO
specific resource in the package is being requested.

Paul

On Mon, Aug 20, 2012 at 2:39 PM, Lukasz Lenart <lu...@apache.org> wrote:
> 2012/8/20 Paul Benedict <pb...@apache.org>:
>> Lukasz,
>>
>> The docs say <default-action-ref/> runs when any URI can't be found in
>> the package. I don't want much liberty. Just when the package matches
>> the URI exactly, have a default action. In regards to configuration,
>> this might be as easy as adding a new attribute to that element. What
>> do you think?
>
> Still don't get it :/ Maybe some example would help...
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> 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


Re: S2 support for index action?

Posted by Lukasz Lenart <lu...@apache.org>.
2012/8/20 Paul Benedict <pb...@apache.org>:
> Lukasz,
>
> The docs say <default-action-ref/> runs when any URI can't be found in
> the package. I don't want much liberty. Just when the package matches
> the URI exactly, have a default action. In regards to configuration,
> this might be as easy as adding a new attribute to that element. What
> do you think?

Still don't get it :/ Maybe some example would help...


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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


Re: S2 support for index action?

Posted by Paul Benedict <pb...@apache.org>.
Lukasz,

The docs say <default-action-ref/> runs when any URI can't be found in
the package. I don't want much liberty. Just when the package matches
the URI exactly, have a default action. In regards to configuration,
this might be as easy as adding a new attribute to that element. What
do you think?

Paul

On Mon, Aug 20, 2012 at 6:22 AM, Lukasz Lenart <lu...@apache.org> wrote:
> 2012/8/5 Paul Benedict <pb...@apache.org>:
>> I see that <default-action-ref> allows an action to execute if the
>> user's path cannot be found. This is almost what I want but not quite.
>> I would like to have an IMPLICIT "index" action for my packages. My
>> configuration does not use any suffix -- everything goes to Struts
>> (i.e., /*) -- so this feature is sensible for my configuration.
>
> I'm not sure if I understand you. You would like to have a different
> <default-action-ref/> by package ?
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> 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


Re: S2 support for index action?

Posted by Lukasz Lenart <lu...@apache.org>.
2012/8/5 Paul Benedict <pb...@apache.org>:
> I see that <default-action-ref> allows an action to execute if the
> user's path cannot be found. This is almost what I want but not quite.
> I would like to have an IMPLICIT "index" action for my packages. My
> configuration does not use any suffix -- everything goes to Struts
> (i.e., /*) -- so this feature is sensible for my configuration.

I'm not sure if I understand you. You would like to have a different
<default-action-ref/> by package ?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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