You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andy Law <an...@roslin.ed.ac.uk> on 2009/08/06 18:51:19 UTC

Is this expected behaviour for tag?

I have actions that sit underneath a set of namespaces. The namespace conveys
a piece of information to the action like a poor-man's REST.

i.e. 
<context>/Cow/ShowDetails.action
<context>/Pig/ShowDetails.action
etc.

I need to construct some links from within the JSP that is hit by the
individual actions and have them point at a different action within the same
namespace

e.g. links generated in the page when accessed via /Cow/ should point to
<context>/Cow/Action2.action and links generated in the page when accessed
via /Pig/ should point to <context>/Pig/Action2.action


If I construct my links to contain href urls derived from <s:url> tags that
look like <s:url action="Action2"> then I get a URL that looks like
<context>/Action2.action. This is no good.


So I figured that I had to set the namespace, which was a pain but I could
always rework the code so that the action knows what namespace it is working
in. I did that, and I set my tag to look like this <s:url action="Action2"
namespace="putItHere"> just to prove that it would work and I ran the
application.

To my surprise, I got a URL that looked like
<context>/Pig/putItHere/Action2.action when I ran through the Pig namespace
and <context>/Cow/putItHere/Action2.action when I ran through the Cow
namespace.

If I rework the namespace to include a leading slash (which was what I
intended to do the first time, but I mistyped it) then my tag looks like
<s:url action="Action2" namespace="/putItHere"> and my URL looks like
<context>/putItHere/Action2.action regardless of which namespace the code is
run through.


So I thought that I would try the obvious thing next and coded my tag to say
<s:url action="Action2" namespace=""> and I got the same outcome as if I had
specified <s:url action="Action2"> i.e. no namespace inserted.


There is NO way that I have found to do what I want to do which is have the
current namespace inserted into the generated URL without anything extra
added.

Have I missed something? (obvious or not so obvious)?

Thanks in advance for anything anyone can suggest.


Later,

Andy
-- 
View this message in context: http://www.nabble.com/Is-this-expected-behaviour-for-%3Cs%3Aurl%3E-tag--tp24850352p24850352.html
Sent from the Struts - User mailing list archive at Nabble.com.


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