Hi Ok this is the code that implements the listener interface: ----------------------------- package com.payvand.seam;
import java.util.List; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import org.hibernate.validator.Valid; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.core.FacesMessages; @Stateless @Name("regis") public class SessionAction implements Listeners{ @In @Valid private User user; @PersistenceContext private EntityManager em; public String register() { // TODO Auto-generated method stub List listUser=em.createQuery("select username from User where username=:username") .setParameter("username",user.getUserName()).getResultList(); if(listUser.size()==0){ em.persist(user); return "/register.jsp"; } else { FacesMessages.instance().add("User #{user.username} already exists"); return null; } } } ----------------- this is the component.xml file : false #{ejbName}/local ---------- here is my ejb-jar.xml: <ejb-jar> <assembly-descriptor> <interceptor-binding> <ejb-name>*</ejb-name> <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class> </interceptor-binding> </assembly-descriptor> </ejb-jar> --- and this is persistence.xml: <persistence-unit name="userDatabase"> org.hibernate.ejb.HibernatePersistence <jta-data-source>java:/DefaultDS</jta-data-source> </persistence-unit> --- and finally this is the JSP file: <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://jboss.com/products/seam/taglib" prefix="s" %> <f:view> <h:form> <s:validateAll> Username <h:inputText value="#{user.userName}" required="true"> Password <h:inputSecret value="#{user.pass}" required="true"> </s:validateAll> <h:messages/> <h:commandButton type="submit" value="Listeners" action="#{regis.register}"> </h:form> </f:view> View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3955242#3955242 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3955242 Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user