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

    Switching locale in email

    Michal Bigos Newbie


      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:

      public class ImportMailer {
           @Logger private Log log;
           private EntityManager entityManager;
           public void scheduleSend(@Duration long startDelay, ImpHistoryFile history) {
                ... preparing for email sending ...
                // TODO use locale from history

      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
      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 ?