No,

code:


Session:

import kk.rentform.session.mailprocessor.AsynchronousMailProcessor;
  | 
  | @Name("regist")
  | @Scope(ScopeType.CONVERSATION)
  | @Stateless
  | public class Regist implements RegistInterface{
  |     @In 
  |     private Usr usr;
  |     
  |     @PersistenceContext
  |     private EntityManager em;
  |     
  |     @In
  |     private FacesMessages facesMessages;
  |     
  |     @Logger
  |     private Log log;
  |     
  |     @In
  |     private AsynchronousMailProcessor asynchronousMailProcessor;
  |     
  |     @In
  |    private  Crypt crypt;
  |     
  |     public String regist(){
  |         if ( ! usr.getPasswort().equals(usr.getPasswort1()) ){
  |             facesMessages.add("Passwörter sind nicht gleich!");
  |             return null;
  |         }
  |         
  |         
  |         
  |         List ls  =   em.createQuery("select u.email from Usr u where 
u.email = :email")
  |         .setParameter("email",usr.getEmail())
  |         .getResultList();
  |         
  |         if ( !ls.isEmpty() ){
  |             facesMessages.add("Email Adresse existiert bereits!");
  |             return null;
  |         }
  |         
  |         List lsb  =   em.createQuery("select u.bname from Usr u where 
u.bname = :bname")
  |         .setParameter("bname",usr.getBname())
  |         .getResultList();
  |         if ( !lsb.isEmpty() ){
  |             facesMessages.add("Benutzername existiert bereits!");
  |             return null;
  |         }
  |         usr.setActive(false);
  |         usr.setSperr(false);
  |         String zf = crypt.generate();
  |         usr.setGennumber(zf);
  |         usr.setRoles("user");
  |         try{
  |             em.persist(usr);
  |             asynchronousMailProcessor.scheduleSend(3000, usr);
  |             return "/registok.xhtml";
  |             
  |         }catch(Exception e){
  |             log.error("---------------- Error : " + e.getMessage());
  |             log.error(e.getStackTrace());
  |             facesMessages.add("Registrierung fehlgeschlagen, versuchen es 
später nochmal.");
  |             return null;
  |         }
  | 
  |         
  |     }
  |     
  | }
  |         


I use this a class from example:



  | import kk.rentform.entity.Usr;
  | import org.jboss.seam.annotations.Asynchronous;
  | import org.jboss.seam.annotations.AutoCreate;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.timer.Duration;
  | import org.jboss.seam.contexts.Contexts;
  | import org.jboss.seam.core.Events;
  | import org.jboss.seam.core.Renderer;
  | 
  | @Name("asynchronousMailProcessor")
  | @AutoCreate
  | public class AsynchronousMailProcessor
  | {
  |    @Asynchronous
  |    public void scheduleSend(@Duration long delay,Usr usr) {
  |       try {
  |          Contexts.getEventContext().set("usr", usr);
  |          Renderer.instance().render("/emailtemplates/registmsg.xhtml");
  |       } catch (Exception e) {
  |          e.printStackTrace();
  |       }
  |    }
  | }
  | 

  | 
  | <m:message xmlns="http://www.w3.org/1999/xhtml";
  |            xmlns:m="http://jboss.com/products/seam/mail";
  |            xmlns:h="http://java.sun.com/jsf/html";>
  |     
  |           <m:from name="xxx" address="xxx" />
  |           <m:to name="#{usr.firma}"> #{usr.email}</m:to>
  |           <m:subject>Registrierung</m:subject>
  |           <m:body>
  |               <p>Sehr geehrte Damen und Herren,</p>
  |             
  |               <p>Um Ihre Registrierung bei rentform.de vervollständigen zu 
können, ist es notwendig Ihren Account freizuschalten.</p>
  |                 <p>Klicken Sie auf den folgenden Link: </p>
  |                 
  |                  <p>Klicken Sie auf den folgenden Link: </p>
  |                 
  |         <p>Peter</p>
  |     </m:body>
  | </m:message>

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4037584#4037584

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4037584

_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to