[jboss-user] [JBoss Seam] - Re: Error during model data update
jason_rency
do-not-reply at jboss.com
Mon Jul 24 04:51:08 EDT 2006
the registerAction.java
package src.reg.server;
|
| import static org.jboss.seam.ScopeType.EVENT;
|
| import java.util.List;
|
| import javax.ejb.Remove;
| import javax.ejb.Stateful;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| import org.jboss.seam.annotations.Destroy;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Scope;
| import org.jboss.seam.core.FacesMessages;
|
| @Stateful
| @Scope(EVENT)
| @Name("register")
| public class RegisterAction implements Register
| {
|
| @In
| private RegUser user;
|
| @PersistenceContext
| private EntityManager em;
|
| @In(create=true)
| private transient FacesMessages facesMessages;
|
| private String PIN;
| private String verify;
|
| public String register()
| {
| System.out.println(PIN);
| System.out.println(user.getUId());
|
| if ( PIN.equals(verify) )
| {
| List existing = em.createQuery("select U_ID from RegUser where U_ID=:UId")
| .setParameter("UId", user.getUId())
| .getResultList();
| if (existing.size()==0)
| {
| //set hashcode of the pin
| user.setPinHash(PIN.hashCode());
| em.persist(user);
| facesMessages.add("Successfully registered as #{user.UId});
| return "login";
| }
| else
| {
| facesMessages.add("Username #{user.UId} already exists");
| return null;
| }
| }
| else
| {
| facesMessages.add("verify", "Re-enter your password");
| verify=null;
| return null;
| }
| }
|
| public String getVerify()
| {
| return verify;
| }
|
| public void setPIN(String PIN)
| {
| this.PIN = PIN;
| }
|
| public String getPIN()
| {
| return PIN;
| }
|
| public void setVerify(String verify)
| {
| this.verify = verify;
| }
|
| @Destroy @Remove
| public void destroy() {}
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960264#3960264
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960264
More information about the jboss-user
mailing list