1 Reply Latest reply on Jul 18, 2007 5:00 AM by Stefano Zaccaria

    EntityManager inside ActionHandler

    Stefano Zaccaria Newbie

      How I can take the EntityManager componenet inside ActionHandler of bpm ?
      And how can take the Renderer component inside ActionHandler?

      Thanks!

        • 1. Re: EntityManager inside ActionHandler
          Stefano Zaccaria Newbie

          For whom might be interested, I have found one solution...

          public class InformaInizioProcesso implements ActionHandler {
          
           private static final long serialVersionUID = 1L;
          
           public void execute(ExecutionContext arg0) throws Exception {
          
           Long idDocumento = (Long)arg0.getVariable("idDocumento");
          
           Renderer renderer = (Renderer)Component.getInstance(Renderer.class);
           EntityManager em = (EntityManager)Component.getInstance("entityManager", true);
          
           Documento doc = (Documento) em.createQuery("select distinct d from Documento d where d.id = :id").setParameter("id", idDocumento).getSingleResult();
          
           Contexts.getEventContext().set("doc", doc);
          
           renderer.render("/mail.xhtml");
          
           }
          
          }