2 Replies Latest reply on Mar 6, 2009 9:26 AM by Michal Bigos

    Switching locale in email

    Michal Bigos Newbie

      Hi,


      could anybody tell me if it is possible to switch locale while rendering email via
      Seam mail tag library asynchronously ?


      I have some component as:



      @Name("importMailer")
      @AutoCreate
      public class ImportMailer {
      
           @Logger private Log log;
           
           @In
           private EntityManager entityManager;
           
           @Asynchronous
           @Transactional
           public void scheduleSend(@Duration long startDelay, ImpHistoryFile history) {
                ... preparing for email sending ...
      
                // TODO use locale from history
                Renderer.instance().render("/email/import_result.xhtml");
           }
      }




      which sends emails and is scheduled asynchronously.


      In history (my entity or bean) I have already locale in which email have to be rendered. But when Seam is rendering email, new event context is created and thus
      MockFacesContext
      created. Default locale from server is taken, even when I try to force Seam to use my own via:



      Contexts.getEventContext().set("org.jboss.seam.core.locale", history.getLocale());




      I'm using Seam version 2.0.2.SP1, but anyway how is proper way to switch locales in asynchronous jobs ?