[jboss-user] [JBoss Seam] - EntityHome validation error (Chapter 14 example)

jfrankman do-not-reply at jboss.com
Thu Apr 26 16:57:11 EDT 2007


I am just getting started with SEAM. I tried the first few examples, and got them working, so in my exuberence I decided to try out the EntityHome example in chapert 14 of the onling doc. Whenever I try to persist the Person, it fails with validation errors. What is interesting is that the validation errors cause the page to fail instead of displaying the errors in the browser like the previous examples do. The root of the problem is:

Caused by: org.hibernate.validator.InvalidStateException: validation failed for: org.jboss.seam.example.registration.Person

I cannot for the life of me figure out why validation is failing. My entity bean, entityhome, and jspx page is displayed below.  Any hints on what the problem is would be appreciated. I have not idea how to troubleshoot this problem, so any help at all would be appreciated.

Entity Bean :

  | @Entity
  | @Table(name="persontable")
  | public class Person {
  |     private Long id;
  |     private String firstName;
  |     private String lastName;
  |     //private Country nationality;
  | 	@Id @NotNull @GeneratedValue
  | 	public Long getId() {
  | 		return id;
  | 	}
  |     @Column(name="firstname",length = 45)
  |     @Length(max = 45)
  | 	public String getFirstName() {
  | 		return firstName;
  | 	}
  | 
  | 	@Column(name="lastname", length = 45)
  | 	@Length(max = 45)
  | 	public String getLastName() {
  | 		return lastName;
  | 	}
  | 
  | 	public void setFirstName(String firstName) {
  | 		this.firstName = firstName;
  | 	}
  | 
  | 	public void setId(Long id) {
  | 		this.id = id;
  | 	}
  | 
  | 	public void setLastName(String lastName) {
  | 		this.lastName = lastName;
  | 	}
  |     
  | }
  | 

EntityHome:

  | @Name("personHome")
  | public class PersonHome extends EntityHome<Person>  {
  |     /**
  | 	 * 
  | 	 */
  | 	private static final long serialVersionUID = 219059304048820709L;
  | 	@RequestParameter Long personId;
  |     @In EntityManager entityManager;
  |     
  |     public Object getId() { return personId; }
  |     public EntityManager getEntityManager() { return entityManager; }
  | 
  | }
  | 

Page:

  | <?xml version="1.0"?>
  | <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" 
  |           xmlns:h="http://java.sun.com/jsf/html"
  |           xmlns:f="http://java.sun.com/jsf/core"
  |           xmlns:s="http://jboss.com/products/seam/taglib"
  |           xmlns="http://www.w3.org/1999/xhtml"
  |           version="2.0">
  |   <jsp:output doctype-root-element="html"
  |               doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
  |               doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
  |   <jsp:directive.page contentType="text/html"/>
  |   <html>
  |   <head>
  |     <title>Register New User</title>
  |   </head>
  |   <body>
  |     <f:view>
  | <h1>Create Person</h1>
  | <h:form>
  | <s:validateAll>
  | 
  |     <div>First name: <h:inputText value="#{personHome.instance.firstName}"/></div>
  |     <div>Last name: <h:inputText value="#{personHome.instance.lastName}"/></div>
  | </s:validateAll>    
  |     <div>
  | 	    <h:messages/>
  |         <h:commandButton value="Create Person" action="#{personHome.persist}"/>
  |     </div>
  |     
  | </h:form>
  |     </f:view>
  |   </body>
  |   </html>
  | </jsp:root>
  | 
  | 

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

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



More information about the jboss-user mailing list