aspose file tools*
The moose likes JBoss/WildFly and the fly likes JBOSS Seam registration problem.  Please help.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "JBOSS Seam registration problem.  Please help...." Watch "JBOSS Seam registration problem.  Please help...." New topic
Author

JBOSS Seam registration problem. Please help....

Benson Fung
Ranch Hand

Joined: Apr 10, 2003
Posts: 213
Hi all,

I followed the JBOSS Seam tutorial to develop registration seam application.
Unfortunately, I always got 3 'Conversion error' messages when I clicked the 'Register' button. There is no any error message in the console so I can't debug what is going on. I had been stuck to this problem for a long time. Please help. The followings are the files :

register.jsp :
<%@ 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" %>
<html>
<head>
<title>Register New User</title>
</head>
<body>
<f:view>
<h:form>
<table border="0">

<s:validateAll>
<tr>
<td>Username</td>
<td><h:inputText value="#{user.username}"/></td>
</tr>
<tr>
<td>Real Name</td>
<td><h:inputText value="#{user.name}"/></td>
</tr>

<tr>
<td>Password</td>
<td><h:inputSecret value="#{user.password}"/></td>
</tr>


</s:validateAll>

</table>
<h:messages/>
<h:commandButton type="submit" value="Register" action="#{register.register}"/>
</h:form>
</f:view>
</body>
</html>

web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<!-- Seam -->

<listener>
<listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
</listener>

<!-- MyFaces -->

<listener>
<listener-class>
org.apache.myfaces.webapp.StartupServletContextListener
</listener-class>
</listener>



<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>


<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.seam</url-pattern>
</servlet-mapping>

</web-app>

faces-config.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config
PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>
<application>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>en-US</supported-locale>
</locale-config>
</application>
<!-- A phase listener is needed by all Seam applications -->

<lifecycle>
<phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>
</lifecycle>

</faces-config>


User.java :
package com.myseam.entity;

import java.io.Serializable;


import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.validator.NotNull;
import org.hibernate.validator.Length;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

@Entity
@Name("user")
@Scope(ScopeType.SESSION)
@Table(name="users")
public class User implements Serializable
{
private static final long serialVersionUID = 1881413500711441951L;

private String username;
private String password;
private String name;

public User(String name, String password, String username)
{
this.name = name;
this.password = password;
this.username = username;
}

public User() { System.out.println("Creating user project.");}

@NotNull @Length(min=5, max=15)
public String getPassword()
{
return password;
}

public void setPassword(String password)
{
System.out.println("password=" + password);
this.password = password;
}

@NotNull
public String getName()
{
return name;
}

public void setName(String name)
{
System.out.println("name=" + name);
this.name = name;
}

@Id @NotNull @Length(min=5, max=15)
public String getUsername()
{
return username;
}

public void setUsername(String username)
{
System.out.println("username=" + username);
this.username = username;
}

}


RegisterAction.java
package com.myseam.session;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.core.FacesMessages;
import org.jboss.seam.log.Log;

import com.myseam.entity.User;
import com.myseam.inf.Register;
import org.jboss.seam.annotations.Name;

@Stateless //(1)
@Name("register")
public class RegisterAction implements Register
{

@In //(2)
private User user;

@PersistenceContext //(3)
private EntityManager em;

@Logger //(4)
private Log log;

public String register() // (5)
{
System.out.println("RegisterAction.register()");
List existing = em.createQuery(
"select username from User where username=#{user.username}") //(6)
.getResultList();

if (existing.size()==0)
{
em.persist(user);
log.info("Registered new user #{user.username}"); //(7)
return "/registered.jsp"; // (8)
}
else
{
FacesMessages.instance().add("User #{user.username} already exists"); // (9)
return null;
}
}

}





Please help
Thanks
Benson
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JBOSS Seam registration problem. Please help....