You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Denis Cabasson (JIRA)" <ji...@apache.org> on 2009/04/16 21:23:06 UTC

[jira] Created: (WW-3090) The ServletUrlRenderer should use the current action / namespace as a default in #renderUrl

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.


[jira] Commented: (WW-3090) The ServletUrlRenderer should use the current action / namespace as a default in #renderUrl

Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-3090?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46064#action_46064 ] 

Wes Wannemacher commented on WW-3090:
-------------------------------------

Denis,

The patch looks good, but I'd also like to see a unit test to make sure we can preserve the behavior in the future. I am looking at org.apache.struts2.views.jsp.URLTagTest and thinking that would be the best place for it to go. I started to try to make one myself, but it is late in my TZ and I need to get some rest. If you can whip up a unit test, I'll get this applied pretty quick. The existing unit tests all pass with your patch applied, so it seems that your patch is good, we just need to add one to verify your intended behavior. Thanks!

> 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
>             Fix For: 2.1.7
>
>         Attachments: WW-3090-patch.txt
>
>
> 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.


[jira] Commented: (WW-3090) The ServletUrlRenderer should use the current action / namespace as a default in #renderUrl

Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-3090?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46065#action_46065 ] 

Wes Wannemacher commented on WW-3090:
-------------------------------------

Denis,

I created a simple unit test, I'm not sure if it is testing exactly what you want and I'll attach it. But, I also noticed a few things while testing out your change on our reference apps. In some cases, it seems to work and in others it does not... For instance, on the struts2-blank app, I put an empty s:url tag on the Welcome.action page and the URL it generated was - /struts2-blank/example/Welcome!execute.action, which, if clicked, does not work. Now in the struts2-showcase app, that sort of link would work. I think it might have to do with the allow dynamic method invocation property, but I don't have time to check into it tonight. 

Another thing I wanted to ask was whether you tried to simply subclass ServletUrlRenderer... I think you could probably make your own version of it and jam it into the framework through the xml configuration. It might be easier for you to do it that way, if possible, then we could add your new version to the framework and make it a configuration option. That way, the option is there and we aren't making a change to an existing component. 

> 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
>             Fix For: 2.1.7
>
>         Attachments: WW-3090-patch.txt
>
>
> 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.


[jira] Issue Comment Edited: (WW-3090) The ServletUrlRenderer should use the current action / namespace as a default in #renderUrl

Posted by "Denis Cabasson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-3090?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46073#action_46073 ] 

Denis Cabasson edited comment on WW-3090 at 4/20/09 2:12 PM:
-------------------------------------------------------------

Hi Wes,

Thank you for taking the time to look into my issue. I'm already using a custom version of the UrlRenderer in my project. However, I found the current behaviour to be wrong (or at least different from my expectations). I was expecting a tag with no action and no value to be the same as a tag with the current action, and it is not the case.
So the point of this ticket is more to see if the behaviour of struts is actually unexpected or not. As far as I am concerned, my project is doing fine.

I have created a new test case, however, I haven't been able to run it yet (as I would need to pull out all of the SNAPSHOT dependencies from one of the SNAPSHOT repository). I will probably give that a shot tommorrow by creating a new local repo so as not to contaminate my current one.

Anyway, the un-expected behaviour only happens if you use a weird action mapper, so I tried providing a simple one in the test case. Feel free to have a look if you have time, and let me know if it is working. Otherwise I will do my best to give it a try tommorrow.

Thanks again for your time.

      was (Author: dcabasson):
    Hi Wes,

Thank you for taking the time to look into my issue. I'm still already using a custom version of the UrlRenderer in my project. However, I found the current behaviour to be wrong (or at least different from my expectations). I was expecting a tag with no action and no value to be the same as a tag with the current action, and it is not the case.
So the point of this ticket is more to see if the behaviour of struts is actually unexpected or not. As far as I am concerned, my project is doing fine.

I have created a new test case, however, I haven't been able to run it yet (as I would need to pull out all of the SNAPSHOT dependencies from one of the SNAPSHOT repository). I will probably give that a shot tommorrow by creating a new local repo so as not to contaminate my current one.

Anyway, the un-expected behaviour only happens if you use a weird action mapper, so I tried providing a simple one in the test case. Feel free to have a look if you have time, and let me know if it is working. Otherwise I will do my best to give it a try tommorrow.

Thanks again for your time.
  
> 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
>             Fix For: 2.1.7
>
>         Attachments: WW-3090-patch.txt, WW-3090-testCase.diff, ww-3090-unit-test.patch
>
>
> 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.


[jira] Updated: (WW-3090) The ServletUrlRenderer should use the current action / namespace as a default in #renderUrl

Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-3090?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Wes Wannemacher updated WW-3090:
--------------------------------

    Attachment: ww-3090-unit-test.patch

possible unit test for patch

> 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
>             Fix For: 2.1.7
>
>         Attachments: WW-3090-patch.txt, ww-3090-unit-test.patch
>
>
> 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.


[jira] Commented: (WW-3090) The ServletUrlRenderer should use the current action / namespace as a default in #renderUrl

Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-3090?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46123#action_46123 ] 

Wes Wannemacher commented on WW-3090:
-------------------------------------

Denis, sorry it took so long to get to this, but I went ahead and tested the patches and they look great. Thanks!

> 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
>             Fix For: 2.1.7
>
>         Attachments: WW-3090-patch-2.diff, WW-3090-patch.txt, WW-3090-test-2.diff, WW-3090-testCase.diff, ww-3090-unit-test.patch
>
>
> 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.


[jira] Commented: (WW-3090) The ServletUrlRenderer should use the current action / namespace as a default in #renderUrl

Posted by "Denis Cabasson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-3090?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46075#action_46075 ] 

Denis Cabasson commented on WW-3090:
------------------------------------

As for the method inclusion, that should probably be removed. I will submit another patch fixing that on tommorrow.

> 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
>             Fix For: 2.1.7
>
>         Attachments: WW-3090-patch.txt, WW-3090-testCase.diff, ww-3090-unit-test.patch
>
>
> 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.


[jira] Updated: (WW-3090) The ServletUrlRenderer should use the current action / namespace as a default in #renderUrl

Posted by "Denis Cabasson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-3090?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Denis Cabasson updated WW-3090:
-------------------------------

    Attachment: WW-3090-testCase.diff

A more complex test case

> 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
>             Fix For: 2.1.7
>
>         Attachments: WW-3090-patch.txt, WW-3090-testCase.diff, ww-3090-unit-test.patch
>
>
> 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.


[jira] Updated: (WW-3090) The ServletUrlRenderer should use the current action / namespace as a default in #renderUrl

Posted by "Musachy Barroso (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-3090?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Musachy Barroso updated WW-3090:
--------------------------------

    Fix Version/s: 2.1.7

> 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
>             Fix For: 2.1.7
>
>         Attachments: WW-3090-patch.txt
>
>
> 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.


[jira] Closed: (WW-3090) The ServletUrlRenderer should use the current action / namespace as a default in #renderUrl

Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-3090?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Wes Wannemacher closed WW-3090.
-------------------------------

    Resolution: Fixed
      Assignee: Wes Wannemacher

Thanks for the patch!

> 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
>            Assignee: Wes Wannemacher
>             Fix For: 2.1.7
>
>         Attachments: WW-3090-patch-2.diff, WW-3090-patch.txt, WW-3090-test-2.diff, WW-3090-testCase.diff, ww-3090-unit-test.patch
>
>
> 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.


[jira] Commented: (WW-3090) The ServletUrlRenderer should use the current action / namespace as a default in #renderUrl

Posted by "Denis Cabasson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-3090?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46073#action_46073 ] 

Denis Cabasson commented on WW-3090:
------------------------------------

Hi Wes,

Thank you for taking the time to look into my issue. I'm still already using a custom version of the UrlRenderer in my project. However, I found the current behaviour to be wrong (or at least different from my expectations). I was expecting a tag with no action and no value to be the same as a tag with the current action, and it is not the case.
So the point of this ticket is more to see if the behaviour of struts is actually unexpected or not. As far as I am concerned, my project is doing fine.

I have created a new test case, however, I haven't been able to run it yet (as I would need to pull out all of the SNAPSHOT dependencies from one of the SNAPSHOT repository). I will probably give that a shot tommorrow by creating a new local repo so as not to contaminate my current one.

Anyway, the un-expected behaviour only happens if you use a weird action mapper, so I tried providing a simple one in the test case. Feel free to have a look if you have time, and let me know if it is working. Otherwise I will do my best to give it a try tommorrow.

Thanks again for your time.

> 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
>             Fix For: 2.1.7
>
>         Attachments: WW-3090-patch.txt, WW-3090-testCase.diff, ww-3090-unit-test.patch
>
>
> 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.


[jira] Updated: (WW-3090) The ServletUrlRenderer should use the current action / namespace as a default in #renderUrl

Posted by "Denis Cabasson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-3090?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Denis Cabasson updated WW-3090:
-------------------------------

    Attachment: WW-3090-patch.txt

Here is my recommended patch to fix that issue.

> 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
>         Attachments: WW-3090-patch.txt
>
>
> 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.


[jira] Updated: (WW-3090) The ServletUrlRenderer should use the current action / namespace as a default in #renderUrl

Posted by "Denis Cabasson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-3090?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Denis Cabasson updated WW-3090:
-------------------------------

    Attachment: WW-3090-test-2.diff
                WW-3090-patch-2.diff

Here is another patch, leaving out the method part, which is probably not needed.

And there goes the test case as well. The code for the test case is a bit messy, as I had to load a different configuration, which is not an easy task with the current testcase. Anyway, you will get the point of the test case, and maybe you will be able to refactor it more elegantly.

So my bottom line is still that the current behaviour is wrong (the test case really is broken with the current configuration). So hopefully you will have a look at this fix!

> 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
>             Fix For: 2.1.7
>
>         Attachments: WW-3090-patch-2.diff, WW-3090-patch.txt, WW-3090-test-2.diff, WW-3090-testCase.diff, ww-3090-unit-test.patch
>
>
> 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.