[jboss-user] [JBoss Seam] - Re: Seam mail ...

minamti do-not-reply at jboss.com
Mon Sep 3 19:59:46 EDT 2007


This is what I have... 

The email page (regemail.xhtml)

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  |                 xmlns:ui="http://java.sun.com/jsf/facelets"
  |                 xmlns:h="http://java.sun.com/jsf/html"
  |                 xmlns:f="http://java.sun.com/jsf/core"
  |                 template="mailtemplate.xhtml">
  |       
  |       <ui:param name="subject" value="foo registration" />
  |       
  |       <ui:define name="body">
  |         <p>Thank you for registering with foo.</p>
  |       	<p>Click on this link to confirm your registration <a href="http://www.foo.com"> foo </a></p>
  |         <p>Happy foo</p>     	      	
  |       </ui:define>
  |       
  | </ui:composition>

The template (mailtemplate.xhtml)

  | <ui:composition xmlns="http://www.w3.org/1999/xhtml"
  |                 xmlns:ui="http://java.sun.com/jsf/facelets"
  |                 xmlns:s="http://jboss.com/products/seam/taglib"
  |                 xmlns:m="http://jboss.com/products/seam/mail"
  |                 xmlns:h="http://java.sun.com/jsf/html"
  |                 xmlns:f="http://java.sun.com/jsf/core">
  |       
  |     <m:message>
  |         <m:from name="foo" address="do-not-reply at foo.com" />
  |         <m:to name="#{user.firstname} #{user.lastname}">#{user.email}</m:to>
  |         <m:subject>#{subject}</m:subject>
  |         <m:body>
  |             <html>
  |                 <body>
  |                     <ui:insert name="body">
  |                         This is the default body, specified by the template.
  |                     </ui:insert>
  |                 </body>
  |             </html>
  |             <f:facet name="alternative">
  |                 <ui:insert name="alternative">
  |                     <h:outputText>Sorry, your mail reader doesn't support html.</h:outputText>
  |                 </ui:insert>
  |             </f:facet>
  |         </m:body>
  |      </m:message>
  |      
  |      <ui:insert name="successMessage">
  |          <html>
  |              <body>
  |              	 <p>An email has been sent to you. Please click on the link in the email to confirm your registration.</p>
  |              </body>
  |          </html>
  |     </ui:insert>
  | </ui:composition>
  | 


If I perform a renderer.render("/regemail.xhtml") it works fine. However, if I have a NotificationBean class defined and try to perform renderer.render in a method pf the NotificationBean, nothing happens. I do not see anything on the screen. The reason why I want a bean is because I need to send this email asynchronously. 

Notification.java
package com.foo.session;
  | 
  | import org.jboss.annotation.ejb.Local;
  | import org.jboss.seam.annotations.async.Asynchronous;
  | 
  | @Local
  | public interface Notification {
  | 
  |         // I tried with the @Asynchronous annotation also
  | 
  | 	public void notifyByEmail(String emailAddress, String firstName, String lastName) throws NotificationException;
  | 	
  | 	
  | }
  | 


NotificationBean.java

package com.foo.session;
  | 
  | import javax.ejb.Remove;
  | import javax.ejb.Stateless;
  | 
  | import org.jboss.seam.annotations.In;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.Out;
  | import org.jboss.seam.annotations.async.Asynchronous;
  | import org.jboss.seam.faces.Renderer;
  | 
  | @Stateless
  | @Name("notification")
  | public class NotificationBean implements Notification {
  | 	
  | 	@In(create=true)
  | 	private Renderer renderer;
  | 	
  | 	public void notifyByEmail(String email, String fName, String lName) throws NotificationException { 
  | 		
  | 			try {
  | 				System.out.println("*************************** Before Rendered ******************************");
  | 				String result = renderer.render("/regemail.xhtml");
  | 				System.out.println("*********************" + result + "*****************");
  | 				System.out.println("*************************** Rendered ******************************");
  | 			}
  | 			catch (Exception e) {
  | 				throw new NotificationException(e.getMessage());
  | 			}
  | 	}
  | 
  | 		
  | }

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

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



More information about the jboss-user mailing list