Uploaded image for project: 'Tapestry'
  1. Tapestry
  2. TAPESTRY-2392

Locale cookie not set after its expiration

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 4.1.5
    • None
    • Framework
    • None

    Description

      The org.apache.tapestry.locale cookie is used in Tapestry to remember last language choice made by the user.

      The problem is, the cookie expires in 7 days, and after it is removed from browser it never gets set again
      until the application is restarted.

      The test case follows.

      Home.html:

      <html jwcid="$content$">
      <body jwcid="@Shell" title="Home">

      <p>
      The current engine locale is: <span jwcid="@Insert" value="ognl:locale" />
      </p>
      <p>
      Cookie received: <span jwcid="@Insert" value="ognl:getCookieSource().readCookieValue('org.apache.tapestry.locale')" />
      </p>

      <p>
      <a href="#" jwcid="@DirectLink" listener="listener:doClick">Set locale to 'et'</a>
      </p>

      </body>
      </html>

      Home.java

      package org.example.pages;

      import java.util.Locale;

      import org.apache.tapestry.IRequestCycle;
      import org.apache.tapestry.PageRedirectException;
      import org.apache.tapestry.annotations.InjectObject;
      import org.apache.tapestry.html.BasePage;
      import org.apache.tapestry.services.CookieSource;
      import org.apache.tapestry.services.ResponseBuilder;

      /**

      • Start page of "myapp".
        */
        abstract public class Home extends BasePage {

      @InjectObject("infrastructure:cookieSource")
      public abstract CookieSource getCookieSource();

      public void doClick(IRequestCycle cycle)

      { Locale locale = new Locale("et"); getEngine().setLocale(locale); cycle.cleanup(); throw new PageRedirectException(getPageName()); }

      }

      Steps to reproduce:
      1) Start the application, go to the Home page (http://localhost:8080/myapp/app)
      2) click "Set locale to 'et'"
      3) go to the Home page again (http://localhost:8080/myapp/app)
      4) you will see that the current locale is "et" and cookie is set accordingly
      5) now simulate cookie expiration by manually removing it from browser
      6) without restarting the application, go to the Home page again
      7) click "Set locale to 'et'"
      8) check that cookie is still not set and you cannot set it without restarting the application

      Expected:
      8) cookie is set

      The bug is similar to TAPESTRY-399, but not the same.

      Workaround: same as in TAPESTRY-399 (set the cookie manually).

      Attachments

        Activity

          People

            Unassigned Unassigned
            altumano Albert Tumanov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: