2 Replies Latest reply on Dec 15, 2010 10:27 AM by Harry P

    help with email & EL in @Asynchronous method

    Don Pruitt Newbie


      I have an asynchronous handler that searches a db table and sends email. That part is working great, however I want to pass some of that info into the rendered email via seam EL. The db query works, the player.firstName info is correct I just can't get it transferred into the rendered text of the email. I know that the info has to be in the seam context so I tried to outject it without any joy. I would greatly appreciate any suggestions.



      timer handler (NewHandHandler.java)

      package org.bitwise.blackbox.session.admin;
      import java.util.*;
      import javax.ejb.Stateless;
      import javax.persistence.*;
      import org.jboss.seam.annotations.async.*;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.AutoCreate;
      import org.jboss.seam.log.Log;
      //import javax.ejb.Timer;
      import org.jboss.seam.faces.Renderer;
      import org.bitwise.blackbox.entity.Hand;
      import org.bitwise.blackbox.entity.Player;
      public class NewHandHandler implements TimerHandLocal {
           //@In(create = true) Timer timer;
          @Logger private Log log;
          @In(create = true)
          private Renderer renderer;
          EntityManager em;
          private Player player;
          private List<Hand> hands;
           public void processNewHands(@IntervalDuration Long interval)
             // implement your business logic here
             List<Hand> results = em.createQuery("select h from Hand as h where h.status = 'new'")
             hands = results;
             Iterator it = hands.iterator();
             while (it.hasNext() )
                  Hand hand = (Hand)it.next();
                  //check for player #1
                  player = hand.getPlyr0Id();
                  if (player != null)
                       log.info("player1:" + player.getEmail());
              //return timer; //note that return value is completely ignored

      email template (NewVideoMail.xhtml)

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <m:message xmlns="http://www.w3.org/1999/xhtml"
         <m:header name="X-Component-By" value="blackbox"/>        
         <m:from name="Don Pruitt" address="dpruitt@bitwiseengineering.com"/>
         <m:to name="Don Pruitt">
         <m:subject>new blackbox video</m:subject>
            <p>Dear #{player.firstName},</p>
            <p>Please note that you have new game play video at
            <a href="http://www.blackbox.com/">