The ServletUrlRenderer should use the current action / namespace as a default
in #renderUrl
-------------------------------------------------------------------------------------------
Key: WW-3090
URL: https://issues.apache.org/struts/browse/WW-3090
Project: Struts 2
Issue Type: Bug
Components: Core Actions
Affects Versions: 2.1.6
Environment: Struts 2.1.6
Reporter: Denis Cabasson
So, here is a bit of a background on the why of that bug.
I' m working for the canadian governement, and there is a strong need to
internationalize applications to be english and french. That goes as far as
bilinguifying the URLs. So the url shouldn't be inbox.action but
*inbox-reception.action* if the locale is English or *reception-inbox.action*
if the locale is French. So, of course, it's a nightmare, but hey, that's what
make the job interesting ;)
Anyway, my approach to enable those weird urls is to use a custom ActionMapper.
Our actions are actually named after their english names, and the action mapper
is adding the French part correctly, and stripping it out when trying to find
the right ActionMapping. That's working fine (after some tweaking of the
Locale, but nothing really important).
So where my issue kicks in is that for bilinguilism we have a link on each page
using a <s:url /> without any actions, so that it redirects to the current page
(with of course a different request_locale).
Now, the thing that happens when we click the link is that the locale changes,
and the url of the page changes. My understanding was that in this case, s:url
would use the current namespace and action to generate the actual url. After
reading through the code, that's the behaviour in
ServletUrlRenderer#renderFormUrl, but ServletUrlRenderer#renderUrl is just
recycling the current URL hoping it will still work. Actually that's not
working in my case, as the URL changes after the Locale switched. So I'd like
for #renderUrl to use the current action / namespace, instead of going for a
wild guess based on the current URL.
In most cases, that doesn't make a difference, as the same page usually have
the same URL. However, it's not the same URL generated in my case, and I think
the behaviour of ServletUrlRenderer is quite unexpected.
I'll try to provide a patch ASAP.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.