You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Jonas Maurus (JIRA)" <ta...@jakarta.apache.org> on 2005/07/14 16:33:32 UTC

[jira] Created: (TAPESTRY-399) If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set

If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set
-------------------------------------------------------------------------------------------------------------------------------------

         Key: TAPESTRY-399
         URL: http://issues.apache.org/jira/browse/TAPESTRY-399
     Project: Tapestry
        Type: Bug
  Components: Framework  
    Versions: 4.0    
    Reporter: Jonas Maurus


At the moment it seems not to be possible to change the engine locale and redirect to the current page so the locale settings take effect immediatly. As you can see I tried doing the redirect manually (via .forward()), but that didn't change a thing.

WORK AROUND -------------------------
  Work-around (this seems to work in Beta 2):
    @InjectObject("infrastructure:cookieSource")
    public abstract CookieSource getCookieSource();

  then in the listener do:
    // note that Locale.toString() returns the programmatic code of the locale (for example "de_DE" or "en_US")
    getCookieSource().writeCookieValue("org.apache.tapestry.locale", Locale.GERMANY.toString());
    throw new RedirectException([myurl]);

TEST CODE -------------------------

template:
    <a jwcid="@ActionLink" stateful="false" listener="ognl:listeners.changeToGerman">de</a>

listener:

    public void changeToGerman(IRequestCycle cycle) {
        cycle.getEngine().setLocale(Locale.GERMANY);
        // this also does not send the cookie
        // cycle.getInfrastructure().getRequest().forward(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getAbsoluteURL());
        throw new RedirectException(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getURL());
    }

    @InjectObject("engine-service:page")
    public abstract IEngineService getEngineService();

Header dump:

actual response:
HTTP/1.x 302 Moved Temporarily
Server: Apache-Coyote/1.1
Location: http://localhost:81/cip/Home.cip
Content-Length: 0
Date: Thu, 14 Jul 2005 14:04:57 GMT

expected response:
HTTP/1.x 302 Moved Temporarily
Server: Apache-Coyote/1.1
Location: http://localhost:81/cip/Home.cip
Content-Length: 0
Date: Thu, 14 Jul 2005 14:04:57 GMT
Set-Cookie: org.apache.tapestry.locale=de_DE; Path=/cip



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


[jira] Updated: (TAPESTRY-399) If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set

Posted by "Jesse Kuhnert (JIRA)" <de...@tapestry.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-399?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jesse Kuhnert updated TAPESTRY-399:
-----------------------------------

    Fix Version/s:     (was: 4.1.2)
                   4.1.3

> If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-399
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-399
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.1.2
>            Reporter: Jonas Maurus
>            Assignee: Jesse Kuhnert
>             Fix For: 4.1.3
>
>
> At the moment it seems not to be possible to change the engine locale and redirect to the current page so the locale settings take effect immediatly. As you can see I tried doing the redirect manually (via .forward()), but that didn't change a thing.
> WORK AROUND -------------------------
>   Work-around (this seems to work in Beta 2):
>     @InjectObject("infrastructure:cookieSource")
>     public abstract CookieSource getCookieSource();
>   then in the listener do:
>     // note that Locale.toString() returns the programmatic code of the locale (for example "de_DE" or "en_US")
>     getCookieSource().writeCookieValue("org.apache.tapestry.locale", Locale.GERMANY.toString());
>     throw new RedirectException([myurl]);
> TEST CODE -------------------------
> template:
>     <a jwcid="@ActionLink" stateful="false" listener="ognl:listeners.changeToGerman">de</a>
> listener:
>     public void changeToGerman(IRequestCycle cycle) {
>         cycle.getEngine().setLocale(Locale.GERMANY);
>         // this also does not send the cookie
>         // cycle.getInfrastructure().getRequest().forward(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getAbsoluteURL());
>         throw new RedirectException(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getURL());
>     }
>     @InjectObject("engine-service:page")
>     public abstract IEngineService getEngineService();
> Header dump:
> actual response:
> HTTP/1.x 302 Moved Temporarily
> Server: Apache-Coyote/1.1
> Location: http://localhost:81/cip/Home.cip
> Content-Length: 0
> Date: Thu, 14 Jul 2005 14:04:57 GMT
> expected response:
> HTTP/1.x 302 Moved Temporarily
> Server: Apache-Coyote/1.1
> Location: http://localhost:81/cip/Home.cip
> Content-Length: 0
> Date: Thu, 14 Jul 2005 14:04:57 GMT
> Set-Cookie: org.apache.tapestry.locale=de_DE; Path=/cip

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Closed: (TAPESTRY-399) If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set

Posted by "Jesse Kuhnert (JIRA)" <ta...@jakarta.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-399?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jesse Kuhnert closed TAPESTRY-399.
----------------------------------

    Resolution: Invalid
      Assignee: Jesse Kuhnert

You can change the locale quite easily by setting it on the engine object instead of trying to muck about with the cookies manually. 

For an example see:

http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/localization/Localization.page?view=markup

Notice the inputLocale component setting the value binding to be "page.engine.locale" . This is what sets it. A running example of it can be found here:

http://opencomponentry.com:8080/workbench/Home,$Border.pageLink.sdirect?sp=Slocalization%2FLocalization

> If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-399
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-399
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.1.2
>            Reporter: Jonas Maurus
>         Assigned To: Jesse Kuhnert
>             Fix For: 4.1.2
>
>
> At the moment it seems not to be possible to change the engine locale and redirect to the current page so the locale settings take effect immediatly. As you can see I tried doing the redirect manually (via .forward()), but that didn't change a thing.
> WORK AROUND -------------------------
>   Work-around (this seems to work in Beta 2):
>     @InjectObject("infrastructure:cookieSource")
>     public abstract CookieSource getCookieSource();
>   then in the listener do:
>     // note that Locale.toString() returns the programmatic code of the locale (for example "de_DE" or "en_US")
>     getCookieSource().writeCookieValue("org.apache.tapestry.locale", Locale.GERMANY.toString());
>     throw new RedirectException([myurl]);
> TEST CODE -------------------------
> template:
>     <a jwcid="@ActionLink" stateful="false" listener="ognl:listeners.changeToGerman">de</a>
> listener:
>     public void changeToGerman(IRequestCycle cycle) {
>         cycle.getEngine().setLocale(Locale.GERMANY);
>         // this also does not send the cookie
>         // cycle.getInfrastructure().getRequest().forward(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getAbsoluteURL());
>         throw new RedirectException(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getURL());
>     }
>     @InjectObject("engine-service:page")
>     public abstract IEngineService getEngineService();
> Header dump:
> actual response:
> HTTP/1.x 302 Moved Temporarily
> Server: Apache-Coyote/1.1
> Location: http://localhost:81/cip/Home.cip
> Content-Length: 0
> Date: Thu, 14 Jul 2005 14:04:57 GMT
> expected response:
> HTTP/1.x 302 Moved Temporarily
> Server: Apache-Coyote/1.1
> Location: http://localhost:81/cip/Home.cip
> Content-Length: 0
> Date: Thu, 14 Jul 2005 14:04:57 GMT
> Set-Cookie: org.apache.tapestry.locale=de_DE; Path=/cip

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Updated: (TAPESTRY-399) If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set

Posted by "Jesse Kuhnert (JIRA)" <ta...@jakarta.apache.org>.
     [ http://issues.apache.org/jira/browse/TAPESTRY-399?page=all ]

Jesse Kuhnert updated TAPESTRY-399:
-----------------------------------

    Affects Version/s: 4.1.2
                           (was: 4.0)

> If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-399
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-399
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.1.2
>            Reporter: Jonas Maurus
>
> At the moment it seems not to be possible to change the engine locale and redirect to the current page so the locale settings take effect immediatly. As you can see I tried doing the redirect manually (via .forward()), but that didn't change a thing.
> WORK AROUND -------------------------
>   Work-around (this seems to work in Beta 2):
>     @InjectObject("infrastructure:cookieSource")
>     public abstract CookieSource getCookieSource();
>   then in the listener do:
>     // note that Locale.toString() returns the programmatic code of the locale (for example "de_DE" or "en_US")
>     getCookieSource().writeCookieValue("org.apache.tapestry.locale", Locale.GERMANY.toString());
>     throw new RedirectException([myurl]);
> TEST CODE -------------------------
> template:
>     <a jwcid="@ActionLink" stateful="false" listener="ognl:listeners.changeToGerman">de</a>
> listener:
>     public void changeToGerman(IRequestCycle cycle) {
>         cycle.getEngine().setLocale(Locale.GERMANY);
>         // this also does not send the cookie
>         // cycle.getInfrastructure().getRequest().forward(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getAbsoluteURL());
>         throw new RedirectException(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getURL());
>     }
>     @InjectObject("engine-service:page")
>     public abstract IEngineService getEngineService();
> Header dump:
> actual response:
> HTTP/1.x 302 Moved Temporarily
> Server: Apache-Coyote/1.1
> Location: http://localhost:81/cip/Home.cip
> Content-Length: 0
> Date: Thu, 14 Jul 2005 14:04:57 GMT
> expected response:
> HTTP/1.x 302 Moved Temporarily
> Server: Apache-Coyote/1.1
> Location: http://localhost:81/cip/Home.cip
> Content-Length: 0
> Date: Thu, 14 Jul 2005 14:04:57 GMT
> Set-Cookie: org.apache.tapestry.locale=de_DE; Path=/cip

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Resolved: (TAPESTRY-399) If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set

Posted by "Jesse Kuhnert (JIRA)" <de...@tapestry.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-399?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jesse Kuhnert resolved TAPESTRY-399.
------------------------------------

    Resolution: Fixed

Ok, should really be fixed now.

> If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-399
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-399
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.1.2
>            Reporter: Jonas Maurus
>            Assignee: Jesse Kuhnert
>             Fix For: 4.1.3
>
>
> At the moment it seems not to be possible to change the engine locale and redirect to the current page so the locale settings take effect immediatly. As you can see I tried doing the redirect manually (via .forward()), but that didn't change a thing.
> WORK AROUND -------------------------
>   Work-around (this seems to work in Beta 2):
>     @InjectObject("infrastructure:cookieSource")
>     public abstract CookieSource getCookieSource();
>   then in the listener do:
>     // note that Locale.toString() returns the programmatic code of the locale (for example "de_DE" or "en_US")
>     getCookieSource().writeCookieValue("org.apache.tapestry.locale", Locale.GERMANY.toString());
>     throw new RedirectException([myurl]);
> TEST CODE -------------------------
> template:
>     <a jwcid="@ActionLink" stateful="false" listener="ognl:listeners.changeToGerman">de</a>
> listener:
>     public void changeToGerman(IRequestCycle cycle) {
>         cycle.getEngine().setLocale(Locale.GERMANY);
>         // this also does not send the cookie
>         // cycle.getInfrastructure().getRequest().forward(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getAbsoluteURL());
>         throw new RedirectException(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getURL());
>     }
>     @InjectObject("engine-service:page")
>     public abstract IEngineService getEngineService();
> Header dump:
> actual response:
> HTTP/1.x 302 Moved Temporarily
> Server: Apache-Coyote/1.1
> Location: http://localhost:81/cip/Home.cip
> Content-Length: 0
> Date: Thu, 14 Jul 2005 14:04:57 GMT
> expected response:
> HTTP/1.x 302 Moved Temporarily
> Server: Apache-Coyote/1.1
> Location: http://localhost:81/cip/Home.cip
> Content-Length: 0
> Date: Thu, 14 Jul 2005 14:04:57 GMT
> Set-Cookie: org.apache.tapestry.locale=de_DE; Path=/cip

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Updated: (TAPESTRY-399) If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set

Posted by "Jesse Kuhnert (JIRA)" <ta...@jakarta.apache.org>.
     [ http://issues.apache.org/jira/browse/TAPESTRY-399?page=all ]

Jesse Kuhnert updated TAPESTRY-399:
-----------------------------------

    Fix Version/s: 4.1.2

> If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-399
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-399
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.1.2
>            Reporter: Jonas Maurus
>             Fix For: 4.1.2
>
>
> At the moment it seems not to be possible to change the engine locale and redirect to the current page so the locale settings take effect immediatly. As you can see I tried doing the redirect manually (via .forward()), but that didn't change a thing.
> WORK AROUND -------------------------
>   Work-around (this seems to work in Beta 2):
>     @InjectObject("infrastructure:cookieSource")
>     public abstract CookieSource getCookieSource();
>   then in the listener do:
>     // note that Locale.toString() returns the programmatic code of the locale (for example "de_DE" or "en_US")
>     getCookieSource().writeCookieValue("org.apache.tapestry.locale", Locale.GERMANY.toString());
>     throw new RedirectException([myurl]);
> TEST CODE -------------------------
> template:
>     <a jwcid="@ActionLink" stateful="false" listener="ognl:listeners.changeToGerman">de</a>
> listener:
>     public void changeToGerman(IRequestCycle cycle) {
>         cycle.getEngine().setLocale(Locale.GERMANY);
>         // this also does not send the cookie
>         // cycle.getInfrastructure().getRequest().forward(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getAbsoluteURL());
>         throw new RedirectException(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getURL());
>     }
>     @InjectObject("engine-service:page")
>     public abstract IEngineService getEngineService();
> Header dump:
> actual response:
> HTTP/1.x 302 Moved Temporarily
> Server: Apache-Coyote/1.1
> Location: http://localhost:81/cip/Home.cip
> Content-Length: 0
> Date: Thu, 14 Jul 2005 14:04:57 GMT
> expected response:
> HTTP/1.x 302 Moved Temporarily
> Server: Apache-Coyote/1.1
> Location: http://localhost:81/cip/Home.cip
> Content-Length: 0
> Date: Thu, 14 Jul 2005 14:04:57 GMT
> Set-Cookie: org.apache.tapestry.locale=de_DE; Path=/cip

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[jira] Reopened: (TAPESTRY-399) If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set

Posted by "Jonas Maurus (JIRA)" <de...@tapestry.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-399?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonas Maurus reopened TAPESTRY-399:
-----------------------------------


I'm sorry, after 1.5 years I didn't monitor this bug closely anymore, so I only just found out that you closed it as invalid and so my response comes a bit late. 

It seems my test code didn't make the issue obvious enough. The problem is not that cycle.engine.setLocale() doesn't work if you send the user to *another* page, like in the workbench, the problem is that it doesn't work if you send the user to *the same page* from an ActionLink using a RedirectException.

For some reason the cookie-header is not set on the response when the exception is thrown, so you can't change the locale and redirect the user.

Setting the cookie *manually* is the work-around. The test code sets the locale on the engine to demonstrate it doesn't work.

You might want to reinvestigate. The test code posted in the description at least doesn't work in version 4.0.2.

> If a RedirectException is thrown after IEngine.setLocale(...) has been called, the cookie org.apache.tapestry.locale is not being set
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-399
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-399
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.1.2
>            Reporter: Jonas Maurus
>         Assigned To: Jesse Kuhnert
>             Fix For: 4.1.2
>
>
> At the moment it seems not to be possible to change the engine locale and redirect to the current page so the locale settings take effect immediatly. As you can see I tried doing the redirect manually (via .forward()), but that didn't change a thing.
> WORK AROUND -------------------------
>   Work-around (this seems to work in Beta 2):
>     @InjectObject("infrastructure:cookieSource")
>     public abstract CookieSource getCookieSource();
>   then in the listener do:
>     // note that Locale.toString() returns the programmatic code of the locale (for example "de_DE" or "en_US")
>     getCookieSource().writeCookieValue("org.apache.tapestry.locale", Locale.GERMANY.toString());
>     throw new RedirectException([myurl]);
> TEST CODE -------------------------
> template:
>     <a jwcid="@ActionLink" stateful="false" listener="ognl:listeners.changeToGerman">de</a>
> listener:
>     public void changeToGerman(IRequestCycle cycle) {
>         cycle.getEngine().setLocale(Locale.GERMANY);
>         // this also does not send the cookie
>         // cycle.getInfrastructure().getRequest().forward(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getAbsoluteURL());
>         throw new RedirectException(getEngineService().getLink(cycle, cycle.getPage().getPageName()).getURL());
>     }
>     @InjectObject("engine-service:page")
>     public abstract IEngineService getEngineService();
> Header dump:
> actual response:
> HTTP/1.x 302 Moved Temporarily
> Server: Apache-Coyote/1.1
> Location: http://localhost:81/cip/Home.cip
> Content-Length: 0
> Date: Thu, 14 Jul 2005 14:04:57 GMT
> expected response:
> HTTP/1.x 302 Moved Temporarily
> Server: Apache-Coyote/1.1
> Location: http://localhost:81/cip/Home.cip
> Content-Length: 0
> Date: Thu, 14 Jul 2005 14:04:57 GMT
> Set-Cookie: org.apache.tapestry.locale=de_DE; Path=/cip

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org