1 Reply Latest reply on Aug 6, 2009 1:31 PM by Wouter van Reeven

    Problem access the configured locale

    Marcos LoisBermudez Newbie
      I'm having problems with locales in a Seam app, my app is distributed as a EAR, i reproduce the problem at small scale, my enviroment is:

      seam-2.1.0.SP1 (In older versions i have the same issue)

      default-locale = gl_ES

      I create a simple home.xhtml page:
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
              <h:outputText value="Locale: #{org.jboss.seam.core.locale}" />

      And a resource servlet:
      public class MyResource extends AbstractResource {

          public String getResourcePath() {
              return "/myresource";

          public void getResource(final HttpServletRequest request, final HttpServletResponse response)
                  throws ServletException, IOException {

              new ContextualHttpServletRequest(request) {
                  public void process() throws IOException {
                      doWork(request, response);

          private void doWork(HttpServletRequest request, HttpServletResponse response) {
              Locale locale = (Locale) Component.getInstance("org.jboss.seam.core.locale");
              try {
                              response.getOutputStream().println("Locale: " + locale);
                      } catch (IOException e) {
                              // TODO Auto-generated catch block

      The problem is that from home page the showed locale is gl_ES, that is correct, the problem apears when i try to get the locale from the resource servlet (A Servlet configured with seam context filter have the same isuue), i always get my jvm default, that is not correct for the application, some content are language especific and need generated in the resource servlet.

      I see the source code of the seam classes implied and in fact org.jboss.core.international.locale checks for session context active, and if not active get the locale from org.jboss.core.locale that gets the jvm default. I review new verion of Seam and I see that a new component LocaleConfig is added, so i need to test with it.

      My question is, from the media servlet i can get de identity of the logged user, with my small understand of seam this is stored in the session scope, so no problems to get identity, but if i want to get the locale, this fallback to jvm defaults.

      There is a configuration for locale that is for the whole app, not only for the UI? If i not use JSF for the UI, how set the locales supported by the app? how acces the default configured locale from a component outside the JSF cycle (ex: a asyncronous task that is schedulet need to know the default locale to format some mail for delivery).