2 Replies Latest reply on Aug 23, 2007 3:13 AM by Benson Fung

    Conversion Error

    vijaya chowdary kurupati Newbie

      hi
      when i click submit button in jspx page i got this error.

      i ran the application like registration.

      
      application.jspx
      
      <?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>Application New User</title>
       </head>
       <body>
       <f:view>
       <h:form>
       <table border="0">
       <s:validateAll>
       <tr>
       <td>Application ID</td>
       <td><h:inputText value="#{app.appID}" required="true"/></td>
       </tr>
       <tr>
       <td>First Name</td>
       <td><h:inputText value="#{app.firstName}" required="true"/></td>
       </tr>
       <tr>
       <td>Last Name</td>
       <td><h:inputText value="#{app.lastName}" required="true"/></td>
       </tr>
       <tr>
       <td>SEX</td>
       <td><h:inputText value="#{app.sex}" required="true"/></td>
       </tr>
       <tr>
       <td>AGE</td>
       <td><h:inputText value="#{app.age}" required="true"/></td>
       </tr>
       </s:validateAll>
       </table>
       <h:messages/>
       <h:commandButton value="Approve" action="#{application.application}"/>
       </h:form>
       </f:view>
       </body>
       </html>
      </jsp:root>
      
      
      ApplicationUser.java
      
      
      package org.jboss.seam.example.application;
      
       import java.io.Serializable;
       import javax.persistence.Entity;
       import javax.persistence.Id;
       import javax.persistence.Table;
      
       import org.hibernate.validator.Length;
       import org.hibernate.validator.NotNull;
       import org.jboss.seam.ScopeType;
       import org.jboss.seam.annotations.Name;
       import org.jboss.seam.annotations.Scope;
      
       @Entity
       @Name("app")
       @Scope(ScopeType.SESSION)
       @Table(name="applications")
      
       public class ApplicationUser implements Serializable
       {
       private int appID;
       private String firstName;
       private String lastName;
       private String sex;
       private int age;
      
       public ApplicationUser(int appID, String firstName, String lastName, String sex, int age)
       {
       this.appID = appID;
       this.firstName = firstName;
       this.lastName = lastName;
       this.sex = sex;
       this.age = age;
       }
      
       public ApplicationUser(){}
      
       //@NotNull @Length(min=1, max=2)
       public int getAge() {
       return age;
       }
      
       public void setAge(int age) {
       this.age = age;
       }
      
       //@Id @NotNull @Length(min=3, max=5)
       public int getAppID() {
       return appID;
       }
      
       public void setAppID(int appID) {
       this.appID = appID;
       }
      
       //@NotNull @Length(min=5, max=15)
       public String getFirstName() {
       return firstName;
       }
      
       public void setFirstName(String firstName) {
       this.firstName = firstName;
       }
      
       // @NotNull @Length(min=5, max=15)
       public String getLastName() {
       return lastName;
       }
      
       public void setLastName(String lastName) {
       this.lastName = lastName;
       }
      
       //@NotNull @Length(min=4, max=6)
       public String getSex() {
       return sex;
       }
      
       public void setSex(String sex) {
       this.sex = sex;
       }
       }
      
      
      
      and ApplicationAction.java
      
      
      package org.jboss.seam.example.application;
      
      import java.util.List;
      
      import javax.ejb.Stateless;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      
      import org.apache.commons.logging.Log;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.core.FacesMessages;
      
      @Stateless
      @Name("application")
      public class ApplicationAction implements Application
      {
       @In
       private ApplicationUser app;
      
       @PersistenceContext
       private EntityManager em;
      
       @Logger
       private Log log;
      
       public String application() {
       List existing=em.createQuery("select appID from ApplicationUser where appID=#(app.appID)").getResultList();
       if(existing.size()==0){
       em.persist(app);
       log.debug("#(ApplicationUser.appID) approved sucessfully");
       return "/appApproved.jspx";
       }
       else{
       FacesMessages.instance().add("#(ApplicationUser.appID) approved already");
       return null;
       }
       }
      
      
      
      
      }
      
      
      
      could you suggest me?
      
      
      
      


        • 1. Re: Conversion Error
          Benson Fung Newbie

          I also got the same problem when I run the example application, registration. It is likely becasue the Seam component, ApplicationUser(in your case), doesn't get instantiated. that's why the property value cannot get set.
          You can try to put the following message in your jsp for little bit more detail

          <h:messages showDetail="true"/>

          I have posted this problem, hopefully, the jboss guy cannot tell me what is going on. Or if you know why, please let me know too.


          Thanks
          Benson

          • 2. Re: Conversion Error
            Benson Fung Newbie

            I also got the same problem when I run the example application, registration. It is likely becasue the Seam component, ApplicationUser(in your case), doesn't get instantiated. that's why the property value cannot get set.
            You can try to put the following message in your jsp for little bit more detail

            <h:messages showDetail="true"/>

            I have posted this problem, hopefully, the jboss guy cannot tell me what is going on. Or if you know why, please let me know too.


            Thanks
            Benson