1 2 3 Previous Next 31 Replies Latest reply on Nov 27, 2006 7:20 AM by newlukai

    Challenge: Simple Example Adding Records With Lookup Dropdow

    johnurban

      I have been unsuccessful in my search to find a seam example on how to create a screen that does the following:

      1. create a table A in your favorite DB. Table A has a foreign key B Id that represents a record in table B.

      A - people

      id
      name
      city
      state
      b_id

      2. create a table B in your favorite DB.

      B - groups

      id
      group
      desc
      date_added

      3. create a screen using seam that allows you go add a record A.
      4. add to this screen a dropdown that allows the user to select a value that represents a record B-group. So now the record gets added with the group value that was selected via the dropdown

      How is this done is seam?

        • 1. Re: Challenge: Simple Example Adding Records With Lookup Dro
          pmuir

          Have you tried the example in my selectitems code (http://jroller.com/page/pmuir?entry=selectitems_revisited). It contains both a select many and select one drop down that will end up being represented as youy suggest.

          If you have problems getting the example running (follow the readme) let me know. There are a couple of bugs in it which I plan to fix later today.

          • 2. Re: Challenge: Simple Example Adding Records With Lookup Dro
            johnurban

            Thanks petemuir. I think you've got me on the right track now. Getting that old null exception again. I've debuged the code and I have exactly 3 rooms in my lists. The count says 3.


            08:03:31,281 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
            java.lang.IllegalArgumentException: Value binding '#{rooms}'of UISelectItems with component-path {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /uQuickPersonAdd.jsp][Class: javax.faces.component.html.HtmlForm,Id: _id2][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: roomId][Class: javax.faces.component.UISelectItems,Id: _id17]} does not reference an Object of type SelectItem, SelectItem[], Collection or Map but of type : null
            at org.apache.myfaces.util.SelectItemsIterator.hasNext(SelectItemsIterator.java:142)
            at org.apache.myfaces.renderkit.RendererUtils.internalGetSelectItemList(RendererUtils.java:485)
            at org.apache.myfaces.renderkit.RendererUtils.getSelectItemList(RendererUtils.java:461)
            at org.apache.myfaces.renderkit.html.HtmlRendererUtils.internalRenderSelect(HtmlRendererUtils.java:272)
            at org.apache.myfaces.renderkit.html.HtmlRendererUtils.renderMenu(HtmlRendererUtils.java:246)
            at org.apache.myfaces.renderkit.html.HtmlMenuRendererBase.encodeEnd(HtmlMenuRendererBase.java:54)
            at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
            at javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:349)
            at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:253)
            at org.apache.jsp.uQuickPersonAdd_jsp._jspx_meth_h_selectOneMenu_0(uQuickPersonAdd_jsp.java:838)
            at org.apache.jsp.uQuickPersonAdd_jsp._jspx_meth_h_form_0(uQuickPersonAdd_jsp.java:323)
            at org.apache.jsp.uQuickPersonAdd_jsp._jspx_meth_f_view_0(uQuickPersonAdd_jsp.java:193)
            at org.apache.jsp.uQuickPersonAdd_jsp._jspService(uQuickPersonAdd_jsp.java:101)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
            at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
            at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415)
            at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
            at org.jboss.seam.jsf.SeamViewHandler.renderView(SeamViewHandler.java:59)
            at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
            at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
            at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
            at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
            at java.lang.Thread.run(Thread.java:613)
            08:03:31,284 ERROR [SeamExceptionFilter] uncaught exception handled by Seam
            javax.servlet.ServletException: Value binding '#{rooms}'of UISelectItems with component-path {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /uQuickPersonAdd.jsp][Class: javax.faces.component.html.HtmlForm,Id: _id2][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: roomId][Class: javax.faces.component.UISelectItems,Id: _id17]} does not reference an Object of type SelectItem, SelectItem[], Collection or Map but of type : null
            at javax.faces.webapp.FacesServlet.service(FacesServlet.java:121)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
            at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
            at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
            at java.lang.Thread.run(Thread.java:613)
            08:03:31,287 INFO [SeamExceptionFilter] killing transaction
            08:03:31,293 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
            javax.faces.FacesException: Value binding '#{rooms}'of UISelectItems with component-path {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /uQuickPersonAdd.jsp][Class: javax.faces.component.html.HtmlForm,Id: _id2][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: roomId][Class: javax.faces.component.UISelectItems,Id: _id17]} does not reference an Object of type SelectItem, SelectItem[], Collection or Map but of type : null
            at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:421)
            at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
            at org.jboss.seam.jsf.SeamViewHandler.renderView(SeamViewHandler.java:59)
            at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
            at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
            at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
            at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
            at java.lang.Thread.run(Thread.java:613)
            Caused by: org.apache.jasper.JasperException: Value binding '#{rooms}'of UISelectItems with component-path {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /uQuickPersonAdd.jsp][Class: javax.faces.component.html.HtmlForm,Id: _id2][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: roomId][Class: javax.faces.component.UISelectItems,Id: _id17]} does not reference an Object of type SelectItem, SelectItem[], Collection or Map but of type : null
            at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
            at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
            at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415)
            ... 25 more
            08:11:19,829 INFO [STDOUT] Person Constructor called
            08:11:19,873 WARN [HtmlLabelRenderer] Unable to find component 'firstName' (calling findComponent on component '_id2:_id5')
            08:11:19,876 WARN [HtmlLabelRenderer] Unable to find component 'lastName' (calling findComponent on component '_id2:_id7')
            08:11:19,878 WARN [HtmlLabelRenderer] Unable to find component 'birthday' (calling findComponent on component '_id2:_id9')
            08:11:19,881 WARN [HtmlLabelRenderer] Unable to find component 'email' (calling findComponent on component '_id2:_id11')
            08:11:19,884 WARN [HtmlLabelRenderer] Unable to find component 'homePhone' (calling findComponent on component '_id2:_id13')
            08:11:19,887 WARN [HtmlLabelRenderer] Unable to find component 'comments' (calling findComponent on component '_id2:_id15')
            08:11:48,068 INFO [STDOUT] Hibernate: select room0_.ID as ID170_, room0_.Name as Name170_, room0_.OrganizationID as Organiza3_170_, room0_.Capacity as Capacity170_ from checkin.room room0_ where room0_.OrganizationID=?
            08:12:18,506 INFO [STDOUT] Hibernate: select room0_.ID as ID170_, room0_.Name as Name170_, room0_.OrganizationID as Organiza3_170_, room0_.Capacity as Capacity170_ from checkin.room room0_ where room0_.OrganizationID=?


            Here is my JSF:

            <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
            <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
             <f:view>
             <f:loadBundle basename="messages" var="msg"/>
             <head>
             <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
             <title>
             <h:outputText value="#{msg.Create} #{msg.Person}" rendered="#{personEditor.new}"/>
             <h:outputText value="#{msg.Update}/#{msg.Delete} #{msg.Person}" rendered="#{!personEditor.new}"/>
             </title>
             <style type="text/css" media="all">
             @import "style/default/screen.css";
             </style>
             </head>
             <body>
            
             <%@ include file="header.htm" %>
            
             <h:form>
            
             <div class="rvgFind">
             <fieldset class="rvgFieldSet">
             <legend><h:outputText value="#{msg.Person} #{msg.Attributes}"/></legend>
            
             <span class="rvgInputs">
             <span class="rvgMeassage"><h:messages globalOnly="true"/></span>
             <h:outputLabel value="#{msg.Person_firstName}" for="firstName">
             <h:inputText value="#{personEditor.instance.firstName}" id="firstName"/>
             <span class="rvgMessage"><h:message for="firstName"/></span>
             </h:outputLabel>
             <h:outputLabel value="#{msg.Person_lastName}" for="lastName">
             <h:inputText value="#{personEditor.instance.lastName}" id="lastName"/>
             <span class="rvgMessage"><h:message for="lastName"/></span>
             </h:outputLabel>
             <h:outputLabel value="#{msg.Person_birthday}" for="birthday">
             <h:inputText value="#{personEditor.instance.birthday}" id="birthday">
             <f:convertDateTime type="date" dateStyle="short"/>
             </h:inputText>
             <span class="rvgMessage"><h:message for="birthday"/></span>
             </h:outputLabel>
            
             <h:outputLabel value="#{msg.Person_email}" for="email">
             <h:inputText value="#{personEditor.instance.email}" id="email"/>
             <span class="rvgMessage"><h:message for="email"/></span>
             </h:outputLabel>
             <h:outputLabel value="#{msg.Person_homePhone}" for="homePhone">
             <h:inputText value="#{personEditor.instance.homePhone}" id="homePhone"/>
             <span class="rvgMessage"><h:message for="homePhone"/></span>
             </h:outputLabel>
             <h:outputLabel value="#{msg.Person_comments}" for="comments">
             <h:inputText value="#{personEditor.instance.comments}" id="comments"/>
             <span class="rvgMessage"><h:message for="comments"/></span>
             </h:outputLabel>
            
             <h:selectOneMenu id="roomId" value="#{person.room}" converter="org.jboss.seam.EntityConverter">
             <f:selectItems value="#{rooms}"/>
             </h:selectOneMenu>
            
             <span class="rvgActions">
             <h:commandButton type="submit" value="#{msg.Create}" action="#{personEditor.create}" rendered="#{personEditor.new}"/>
             </span>
            
             </fieldset>
             </div>
            
             </h:form>
            
             </body>
             </f:view>
            </html>
            


            Here is my Person object:

            package testSeam;
            
            // Generated Sep 23, 2006 1:30:00 PM by Hibernate Tools 3.2.0.beta7
            
            import java.util.Date;
            import javax.persistence.Column;
            import javax.persistence.Entity;
            import javax.persistence.Id;
            import javax.persistence.Table;
            import javax.persistence.OneToOne;
            import javax.persistence.ManyToOne;
            
            /**
             * Person generated by hbm2java
             */
            @Entity
            @Table(name = "person", catalog = "checkin", uniqueConstraints = {})
            public class Person implements java.io.Serializable {
            
             // Fields
            
             private int id;
            
             @ManyToOne
             private Room room;
            
             @ManyToOne
             private Organization organization;
            
             private String firstName;
            
             private String middleName;
            
             private String lastName;
            
             private String address1;
            
             private String city;
            
             private String state;
            
             private String zip;
            
             private String email;
            
             private Date birthday;
            
             private Long sex;
            
             private String homePhone;
            
             private String workPhone;
            
             private String beeperPhone;
            
             private String cellPhone;
            
             private String extraPhone;
            
             private String extraPhoneMemo;
            
             private String school;
            
             private String schoolGrade;
            
             private String contact;
            
             private String parentName;
            
             private String comments;
            
             private String minsitry;
            
             private Character drama;
            
             private Character music;
            
             private Long status;
            
             private Character visitor;
            
             private Character mailList;
            
             private Character leader;
            
             private Date lastAttended;
            
             private Date created;
            
             private Date updated;
            
             private Character vcall;
            
             private Character vhouseCall;
            
             private String team;
            
             private String photoFile;
            
             private String uniqueId;
            
             // Constructors
            
             /** default constructor */
             public Person() {
             System.out.println("Person Constructor called");
             }
            
             /** minimal constructor */
             /*
             public Person(int id, int roomId, int organizationId, String firstName) {
             System.out.println("Person Constructor called with 3 parms");
             this.id = id;
             this.roomId = roomId;
             this.organizationId = organizationId;
             this.firstName = firstName;
             }
             */
            
             /** full constructor */
             /*
             public Person(int id, int roomId, int organizationId, String firstName,
             String middleName, String lastName, String address1, String city,
             String state, String zip, String email, Date birthday, Long sex,
             String homePhone, String workPhone, String beeperPhone,
             String cellPhone, String extraPhone, String extraPhoneMemo,
             String school, String schoolGrade, String contact,
             String parentName, String comments, String minsitry,
             Character drama, Character music, Long status, Character visitor,
             Character mailList, Character leader, Date lastAttended,
             Date created, Date updated, Character vcall, Character vhouseCall,
             String team, String photoFile, String uniqueId) {
             System.out.println("Person Constructor called with ALL parms");
             this.id = id;
             this.roomId = roomId;
             this.organizationId = organizationId;
             this.firstName = firstName;
             this.middleName = middleName;
             this.lastName = lastName;
             this.address1 = address1;
             this.city = city;
             this.state = state;
             this.zip = zip;
             this.email = email;
             this.birthday = birthday;
             this.sex = sex;
             this.homePhone = homePhone;
             this.workPhone = workPhone;
             this.beeperPhone = beeperPhone;
             this.cellPhone = cellPhone;
             this.extraPhone = extraPhone;
             this.extraPhoneMemo = extraPhoneMemo;
             this.school = school;
             this.schoolGrade = schoolGrade;
             this.contact = contact;
             this.parentName = parentName;
             this.comments = comments;
             this.minsitry = minsitry;
             this.drama = drama;
             this.music = music;
             this.status = status;
             this.visitor = visitor;
             this.mailList = mailList;
             this.leader = leader;
             this.lastAttended = lastAttended;
             this.created = created;
             this.updated = updated;
             this.vcall = vcall;
             this.vhouseCall = vhouseCall;
             this.team = team;
             this.photoFile = photoFile;
             this.uniqueId = uniqueId;
             }
             */
            
             // Property accessors
             @Id
             @Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true)
             public int getId() {
             return this.id;
             }
            
             public void setId(int id) {
             this.id = id;
             }
            
             // @Column(name = "RoomID", unique = false, nullable = false, insertable = true, updatable = true)
             public Room getRoom() {
             return this.room;
             }
            
             public void setRoom(Room room) {
             this.room = room;
             }
            
             // @Column(name = "OrganizationID", unique = false, nullable = false, insertable = true, updatable = true)
             public Organization getOrganization() {
             return organization;
             }
            
             public void setOrganization(Organization organization) {
             this.organization = organization;
             }
            
             @Column(name = "FirstName", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
             public String getFirstName() {
             return this.firstName;
             }
            
             public void setFirstName(String firstName) {
             this.firstName = firstName;
             }
            
             @Column(name = "MiddleName", unique = false, nullable = true, insertable = true, updatable = true, length = 20)
             public String getMiddleName() {
             return this.middleName;
             }
            
             public void setMiddleName(String middleName) {
             this.middleName = middleName;
             }
            
             @Column(name = "LastName", unique = false, nullable = true, insertable = true, updatable = true, length = 25)
             public String getLastName() {
             return this.lastName;
             }
            
             public void setLastName(String lastName) {
             this.lastName = lastName;
             }
            
             @Column(name = "Address1", unique = false, nullable = true, insertable = true, updatable = true, length = 90)
             public String getAddress1() {
             return this.address1;
             }
            
             public void setAddress1(String address1) {
             this.address1 = address1;
             }
            
             @Column(name = "City", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
             public String getCity() {
             return this.city;
             }
            
             public void setCity(String city) {
             this.city = city;
             }
            
             @Column(name = "State", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
             public String getState() {
             return this.state;
             }
            
             public void setState(String state) {
             this.state = state;
             }
            
             @Column(name = "Zip", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
             public String getZip() {
             return this.zip;
             }
            
             public void setZip(String zip) {
             this.zip = zip;
             }
            
             @Column(name = "EMail", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
             public String getEmail() {
             return this.email;
             }
            
             public void setEmail(String email) {
             this.email = email;
             }
            
             @Column(name = "Birthday", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
             public Date getBirthday() {
             return this.birthday;
             }
            
             public void setBirthday(Date birthday) {
             this.birthday = birthday;
             }
            
             @Column(name = "Sex", unique = false, nullable = true, insertable = true, updatable = true, precision = 10, scale = 0)
             public Long getSex() {
             return this.sex;
             }
            
             public void setSex(Long sex) {
             this.sex = sex;
             }
            
             @Column(name = "HomePhone", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
             public String getHomePhone() {
             return this.homePhone;
             }
            
             public void setHomePhone(String homePhone) {
             this.homePhone = homePhone;
             }
            
             @Column(name = "WorkPhone", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
             public String getWorkPhone() {
             return this.workPhone;
             }
            
             public void setWorkPhone(String workPhone) {
             this.workPhone = workPhone;
             }
            
             @Column(name = "BeeperPhone", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
             public String getBeeperPhone() {
             return this.beeperPhone;
             }
            
             public void setBeeperPhone(String beeperPhone) {
             this.beeperPhone = beeperPhone;
             }
            
             @Column(name = "CellPhone", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
             public String getCellPhone() {
             return this.cellPhone;
             }
            
             public void setCellPhone(String cellPhone) {
             this.cellPhone = cellPhone;
             }
            
             @Column(name = "ExtraPhone", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
             public String getExtraPhone() {
             return this.extraPhone;
             }
            
             public void setExtraPhone(String extraPhone) {
             this.extraPhone = extraPhone;
             }
            
             @Column(name = "ExtraPhoneMemo", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
             public String getExtraPhoneMemo() {
             return this.extraPhoneMemo;
             }
            
             public void setExtraPhoneMemo(String extraPhoneMemo) {
             this.extraPhoneMemo = extraPhoneMemo;
             }
            
             @Column(name = "School", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
             public String getSchool() {
             return this.school;
             }
            
             public void setSchool(String school) {
             this.school = school;
             }
            
             @Column(name = "SchoolGrade", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
             public String getSchoolGrade() {
             return this.schoolGrade;
             }
            
             public void setSchoolGrade(String schoolGrade) {
             this.schoolGrade = schoolGrade;
             }
            
             @Column(name = "Contact", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
             public String getContact() {
             return this.contact;
             }
            
             public void setContact(String contact) {
             this.contact = contact;
             }
            
             @Column(name = "ParentName", unique = false, nullable = true, insertable = true, updatable = true, length = 75)
             public String getParentName() {
             return this.parentName;
             }
            
             public void setParentName(String parentName) {
             this.parentName = parentName;
             }
            
             @Column(name = "Comments", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
             public String getComments() {
             return this.comments;
             }
            
             public void setComments(String comments) {
             this.comments = comments;
             }
            
             @Column(name = "Minsitry", unique = false, nullable = true, insertable = true, updatable = true, length = 60)
             public String getMinsitry() {
             return this.minsitry;
             }
            
             public void setMinsitry(String minsitry) {
             this.minsitry = minsitry;
             }
            
             @Column(name = "Drama", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
             public Character getDrama() {
             return this.drama;
             }
            
             public void setDrama(Character drama) {
             this.drama = drama;
             }
            
             @Column(name = "Music", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
             public Character getMusic() {
             return this.music;
             }
            
             public void setMusic(Character music) {
             this.music = music;
             }
            
             @Column(name = "Status", unique = false, nullable = true, insertable = true, updatable = true, precision = 10, scale = 0)
             public Long getStatus() {
             return this.status;
             }
            
             public void setStatus(Long status) {
             this.status = status;
             }
            
             @Column(name = "Visitor", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
             public Character getVisitor() {
             return this.visitor;
             }
            
             public void setVisitor(Character visitor) {
             this.visitor = visitor;
             }
            
             @Column(name = "Mail_List", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
             public Character getMailList() {
             return this.mailList;
             }
            
             public void setMailList(Character mailList) {
             this.mailList = mailList;
             }
            
             @Column(name = "Leader", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
             public Character getLeader() {
             return this.leader;
             }
            
             public void setLeader(Character leader) {
             this.leader = leader;
             }
            
             @Column(name = "Last_Attended", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
             public Date getLastAttended() {
             return this.lastAttended;
             }
            
             public void setLastAttended(Date lastAttended) {
             this.lastAttended = lastAttended;
             }
            
             @Column(name = "Created", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
             public Date getCreated() {
             return this.created;
             }
            
             public void setCreated(Date created) {
             this.created = created;
             }
            
             @Column(name = "Updated", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
             public Date getUpdated() {
             return this.updated;
             }
            
             public void setUpdated(Date updated) {
             this.updated = updated;
             }
            
             @Column(name = "VCall", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
             public Character getVcall() {
             return this.vcall;
             }
            
             public void setVcall(Character vcall) {
             this.vcall = vcall;
             }
            
             @Column(name = "VHouseCall", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
             public Character getVhouseCall() {
             return this.vhouseCall;
             }
            
             public void setVhouseCall(Character vhouseCall) {
             this.vhouseCall = vhouseCall;
             }
            
             @Column(name = "Team", unique = false, nullable = true, insertable = true, updatable = true, length = 17)
             public String getTeam() {
             return this.team;
             }
            
             public void setTeam(String team) {
             this.team = team;
             }
            
             @Column(name = "PhotoFile", unique = false, nullable = true, insertable = true, updatable = true, length = 75)
             public String getPhotoFile() {
             return this.photoFile;
             }
            
             public void setPhotoFile(String photoFile) {
             this.photoFile = photoFile;
             }
            
             @Column(name = "UniqueID", unique = false, nullable = true, insertable = true, updatable = true, length = 45)
             public String getUniqueId() {
             return this.uniqueId;
             }
            
             public void setUniqueId(String uniqueId) {
             this.uniqueId = uniqueId;
             }
            
            }
            
            


            Here is my Room object:

            package testSeam;
            
            // Generated Oct 6, 2006 12:55:26 AM by Hibernate Tools 3.2.0.beta7
            
            import javax.persistence.Column;
            import javax.persistence.Entity;
            import javax.persistence.Id;
            import javax.persistence.Table;
            
            /**
             * Room generated by hbm2java
             */
            @Entity
            @Table(name = "room", catalog = "checkin", uniqueConstraints = {})
            public class Room implements java.io.Serializable {
            
             // Fields
            
             private int id;
            
             private String name;
            
             private int organizationId;
            
             private int capacity;
            
             // Constructors
            
             /** default constructor */
             public Room() {
             }
            
             /** full constructor */
             public Room(int id, String name, int organizationId, int capacity) {
             this.id = id;
             this.name = name;
             this.organizationId = organizationId;
             this.capacity = capacity;
             }
            
             // Property accessors
             @Id
             @Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true)
             public int getId() {
             return this.id;
             }
            
             public void setId(int id) {
             this.id = id;
             }
            
             @Column(name = "Name", unique = false, nullable = false, insertable = true, updatable = true, length = 50)
             public String getName() {
             return this.name;
             }
            
             public void setName(String name) {
             this.name = name;
             }
            
             @Column(name = "OrganizationID", unique = false, nullable = false, insertable = true, updatable = true)
             public int getOrganizationId() {
             return this.organizationId;
             }
            
             public void setOrganizationId(int organizationId) {
             this.organizationId = organizationId;
             }
            
             @Column(name = "Capacity", unique = false, nullable = false, insertable = true, updatable = true)
             public int getCapacity() {
             return this.capacity;
             }
            
             public void setCapacity(int capacity) {
             this.capacity = capacity;
             }
            
            }
            
            


            Here is my PersonEditorBean:

            package testSeam;
            
            // Generated Sep 23, 2006 1:30:01 PM by Hibernate Tools 3.2.0.beta7
            
            import java.util.ArrayList;
            import java.util.HashMap;
            import java.util.Iterator;
            import java.util.List;
            import java.util.Map;
            import java.util.Map.Entry;
            
            import javax.ejb.Remove;
            import javax.ejb.Stateful;
            import javax.ejb.TransactionAttribute;
            import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
            import javax.faces.application.FacesMessage;
            import javax.faces.context.FacesContext;
            import javax.faces.model.SelectItem;
            import javax.interceptor.Interceptors;
            import javax.persistence.EntityManager;
            import javax.persistence.Query;
            
            import org.hibernate.validator.Valid;
            import org.jboss.seam.ScopeType;
            import org.jboss.seam.annotations.Begin;
            import org.jboss.seam.annotations.Destroy;
            import org.jboss.seam.annotations.End;
            import org.jboss.seam.annotations.Factory;
            import org.jboss.seam.annotations.IfInvalid;
            import org.jboss.seam.annotations.In;
            import org.jboss.seam.annotations.Name;
            import org.jboss.seam.annotations.Outcome;
            import org.jboss.seam.annotations.Scope;
            import org.jboss.seam.ejb.SeamInterceptor;
            
            import org.jboss.seam.selectitems.annotations.*;
            import org.jboss.seam.selectitems.databinding.*;
            
            @Name("personEditor")
            @Stateful
            @Scope(ScopeType.SESSION)
            @Interceptors(SeamInterceptor.class)
            public class PersonEditorBean implements PersonEditor {
            
             @In(create = true)
             private EntityManager entityManager;
            
             @In(required=false)
             private Login login;
            
             @Valid
             private Person instance = new Person();
            
             @SelectItems(label="description", addNoSelectionLabel="Please select...")
             private List<Room> rooms;
            
             private boolean isNew = true;
            
             private String doneOutcome = "find";
            
             @TransactionAttribute(NOT_SUPPORTED)
             public Person getInstance() {
             // System.out.println("PersonEditorBean.getInstance|");
             return instance;
             }
            
             public void setInstance(Person instance) {
             this.instance = instance;
             }
            
             @TransactionAttribute(NOT_SUPPORTED)
             public boolean isNew() {
             // System.out.println("PersonEditorBean.isNew|"+isNew);
             return isNew;
             }
            
             public void setNew(boolean isNew) {
             this.isNew = isNew;
             }
            
             public void setDoneOutcome(String outcome) {
             doneOutcome = outcome;
             }
            
             @In(required = false)
             private transient PersonFinder personFinder;
            
             @In(create = true)
             private transient Map messages;
            
             @SuppressWarnings("unchecked")
             @Factory("rooms")
             public void getRoomListByOrganization() { // f:selectItems value
             Map<String, Object> parameters = new HashMap<String, Object>();
             StringBuffer queryString = new StringBuffer();
             Users loggedInUser = login.getInstance();
            
             queryString.append(" and room.organizationId = :organizationId");
             parameters.put("organizationId", loggedInUser.getOrganizationId());
            
             if (queryString.length() == 0) {
             queryString.append("select room from Room room");
             } else {
             queryString.delete(0, 4).insert(0,
             "select room from Room room where");
             }
            
             Query query = entityManager.createQuery(queryString.toString());
             for (Entry<String, Object> param : parameters.entrySet()) {
             query.setParameter(param.getKey(), param.getValue());
             }
             rooms = (List<Room>) query.getResultList();
            
            // List selectItems=new ArrayList();
            // for (Iterator iterator = roomListByOrganization.iterator(); iterator.hasNext();)
            // {
            // Room value = (Room)iterator.next();
            // SelectItem item = new SelectItem(value, value.getName());
            // selectItems.add(item);
            // }
            //
            // roomListByOrganization = selectItems;
            //
             // return roomListByOrganization;
             }
            
             @Begin(join = true)
             @LoggedIn
             @IfInvalid(outcome = Outcome.REDISPLAY)
             public String create() {
             if (entityManager.find(Person.class, instance.getId()) != null) {
             FacesContext.getCurrentInstance().addMessage(
             null,
             new FacesMessage(messages.get("Person_id") + " "
             + messages.get("AlreadyExists")));
             return null;
             }
             entityManager.persist(instance);
             isNew = false;
             refreshFinder();
             return "editPerson";
             }
            
             @IfInvalid(outcome = Outcome.REDISPLAY)
             public String update() {
             refreshFinder();
             return null;
             }
            
             @End(ifOutcome = "find")
             public String delete() {
             entityManager.remove(instance);
             refreshFinder();
             return doneOutcome;
             }
            
             @End(ifOutcome = "find")
             public String done() {
             if (!isNew)
             entityManager.refresh(instance);
             return doneOutcome;
             }
            
             private void refreshFinder() {
             if (personFinder != null)
             personFinder.refresh();
             }
            
             @Destroy
             @Remove
             public void destroy() {
             }
            
            }
            
            


            • 3. Re: Challenge: Simple Example Adding Records With Lookup Dro
              pmuir

              I'm still concerned about personEditor having a SESSION scope [1]. I would suggest trying a really simple stateless session bean that just returns all the rooms in your data:

              ...
              @SelectItems(label="description")
              List<Room> allRooms;
              
              @Factory("allRooms")
              void getRoomList() {
               allRooms = entityManager.createQuery("select room from Room room").getResultList();
              }
              ...


              and see if you can get that displaying on your JSF page. Then work up from there.

              In general I would suggest always using much simpler jsf/beans whilst debugging something like this and working up to a complex setup - something else could be causing the problem but be hidden.

              The example is probably a good place to start - the only reason the backing bean is conversational is to show state being saved, the interesting stuff (@SelectItems) could easily be stateless.

              • 4. Re: Challenge: Simple Example Adding Records With Lookup Dro
                johnurban

                Thanks.

                Looks like my decision to add to the already generated code was a bad idea. I like your idea of simplifying. So that brings me to a design question:

                In this case should I create a new SLSB to persist the new person record rather than the generated PersonEditorBen(SFSB)?

                If I do create a new SLSB, can I make it do the room lookup, extract the data from jsp and add the record to the person table. Or, does this SLSB need be to specifically for the room lookup?

                If so, do I always need to user SLSB when doing fancy dropdown lookups on tables?

                In Seam what are the best guidelines for determining when/when not to use SLSB/SFSB?

                • 5. Re: Challenge: Simple Example Adding Records With Lookup Dro
                  pmuir

                   

                  In Seam what are the best guidelines for determining when/when not to use SLSB/SFSB?


                  This is an interesting question. I think the answer depends on style/what you are doing.

                  I'm increasingly using the pattern of a stateful component to manage the flow and a stateless 'service' bean to do the rest of the work. I use bijection to pass any object required (so far only entities) between them.

                  The advantage of this approach I find is that, firstly, you seperate workflow logic from 'helper' methods resulting in clearer code (for example, deleting a user vs. reseting the password), secondly, it makes the 'helper' methods resuable (e.g. a nationality dropdown might be used in various places in your ui, so you want its content to be generated in a stateless fashion).

                  The disadvantage is complexity - and I am developing a complex workflow involving jbpm.

                  So, what I would do is create a 'roomService' bean which contains any non-workflow-related methods for rooms (e.g. drop down lists, generating access codes), and a 'roomCRUD' bean that contains the workflow methods. That doesn't mean its the best approach but it works well for me and avoids a lot of the concurrent access problems to stateful beans (though I believe the new seam fixes this).

                  • 6. Re: Challenge: Simple Example Adding Records With Lookup Dro
                    johnurban

                    I was able to get the example working after closely following your example Mr. Muir. Thank you.

                    In your example you have Client and ClientType POJO's. My next hurdle is getting the Client object to persist from a JSF. Is there an example already out there showing how to persist an object that has a dropdown/lookup, reference as an @ManyToOne?

                    My JSF seems to pass validation, however I keep getting

                    "unable to access entity manager"

                    as a return message in my JSF. No exceptions come up the stack trace and the action event never gets called. So, some magic is happening between jsf submit and RoomServiceBean.

                    JSF

                    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
                    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
                    
                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
                     <f:view>
                     <f:loadBundle basename="messages" var="msg"/>
                     <head>
                     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                     <title>
                     <h:outputText value="#{msg.Create} #{msg.Person}" rendered="#{roomService.new}"/>
                     </title>
                     <style type="text/css" media="all">
                     @import "style/default/screen.css";
                     </style>
                     </head>
                     <body>
                    
                     <%@ include file="header.htm" %>
                    
                     <h:form>
                    
                     <div class="rvgFind">
                     <fieldset class="rvgFieldSet">
                     <legend><h:outputText value="#{msg.Person} #{msg.Attributes}"/></legend>
                    
                     <span class="rvgInputs">
                     <span class="rvgMeassage"><h:messages globalOnly="false"/></span>
                    
                     <h:selectOneMenu value="#{person.room}" converter="org.jboss.seam.EntityConverter">
                     <f:selectItems value="#{rooms}" />
                     </h:selectOneMenu>
                     <h:selectOneMenu value="#{person.organization}" converter="org.jboss.seam.EntityConverter">
                     <f:selectItems value="#{organizations}" />
                     </h:selectOneMenu>
                    
                     <h:outputLabel value="#{msg.Person_firstName}">
                     <h:inputText value="#{person.firstName}" id="firstName"/>
                     <span class="rvgMessage"><h:message for="firstName"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_middleName}">
                     <h:inputText value="#{person.middleName}" id="middleName"/>
                     <span class="rvgMessage"><h:message for="middleName"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_lastName}">
                     <h:inputText value="#{person.lastName}" id="lastName"/>
                     <span class="rvgMessage"><h:message for="lastName"/></span>
                     </h:outputLabel>
                    
                     <h:outputLabel value="#{msg.Person_birthday}" for="birthday">
                     <h:inputText value="#{person.birthday}" id="birthday">
                     <f:convertDateTime type="date" dateStyle="short"/>
                     </h:inputText>
                     <span class="rvgMessage"><h:message for="birthday"/></span>
                     </h:outputLabel>
                    
                     <h:outputLabel value="#{msg.Person_address1}" for="address1">
                     <h:inputText value="#{person.address1}" id="address1"/>
                     <span class="rvgMessage"><h:message for="address1"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_city}" for="city">
                     <h:inputText value="#{person.city}" id="city"/>
                     <span class="rvgMessage"><h:message for="city"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_state}" for="state">
                     <h:inputText value="#{person.state}" id="state"/>
                     <span class="rvgMessage"><h:message for="state"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_zip}" for="zip">
                     <h:inputText value="#{person.zip}" id="zip"/>
                     <span class="rvgMessage"><h:message for="zip"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_email}" for="email">
                     <h:inputText value="#{person.email}" id="email"/>
                     <span class="rvgMessage"><h:message for="email"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_sex}" for="sex">
                     <h:inputText value="#{person.sex}" id="sex"/>
                     <span class="rvgMessage"><h:message for="sex"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_homePhone}" for="homePhone">
                     <h:inputText value="#{person.homePhone}" id="homePhone"/>
                     <span class="rvgMessage"><h:message for="homePhone"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_workPhone}" for="workPhone">
                     <h:inputText value="#{person.workPhone}" id="workPhone"/>
                     <span class="rvgMessage"><h:message for="workPhone"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_beeperPhone}" for="beeperPhone">
                     <h:inputText value="#{person.beeperPhone}" id="beeperPhone"/>
                     <span class="rvgMessage"><h:message for="beeperPhone"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_cellPhone}" for="cellPhone">
                     <h:inputText value="#{person.cellPhone}" id="cellPhone"/>
                     <span class="rvgMessage"><h:message for="cellPhone"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_extraPhone}" for="extraPhone">
                     <h:inputText value="#{person.extraPhone}" id="extraPhone"/>
                     <span class="rvgMessage"><h:message for="extraPhone"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_extraPhoneMemo}" for="extraPhoneMemo">
                     <h:inputText value="#{person.extraPhoneMemo}" id="extraPhoneMemo"/>
                     <span class="rvgMessage"><h:message for="extraPhoneMemo"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_school}" for="school">
                     <h:inputText value="#{person.school}" id="school"/>
                     <span class="rvgMessage"><h:message for="school"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_schoolGrade}" for="schoolGrade">
                     <h:inputText value="#{person.schoolGrade}" id="schoolGrade"/>
                     <span class="rvgMessage"><h:message for="schoolGrade"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_contact}" for="contact">
                     <h:inputText value="#{person.contact}" id="contact"/>
                     <span class="rvgMessage"><h:message for="contact"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_parentName}" for="parentName">
                     <h:inputText value="#{person.parentName}" id="parentName"/>
                     <span class="rvgMessage"><h:message for="parentName"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_comments}" for="comments">
                     <h:inputText value="#{person.comments}" id="comments"/>
                     <span class="rvgMessage"><h:message for="comments"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_minsitry}" for="minsitry">
                     <h:inputText value="#{person.minsitry}" id="minsitry"/>
                     <span class="rvgMessage"><h:message for="minsitry"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_drama}" for="drama">
                     <h:inputText value="#{person.drama}" id="drama"/>
                     <span class="rvgMessage"><h:message for="drama"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_music}" for="music">
                     <h:inputText value="#{person.music}" id="music"/>
                     <span class="rvgMessage"><h:message for="music"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_status}" for="status">
                     <h:inputText value="#{person.status}" id="status"/>
                     <span class="rvgMessage"><h:message for="status"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_visitor}" for="visitor">
                     <h:inputText value="#{person.visitor}" id="visitor"/>
                     <span class="rvgMessage"><h:message for="visitor"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_mailList}" for="mailList">
                     <h:inputText value="#{person.mailList}" id="mailList"/>
                     <span class="rvgMessage"><h:message for="mailList"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_leader}" for="leader">
                     <h:inputText value="#{person.leader}" id="leader"/>
                     <span class="rvgMessage"><h:message for="leader"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_lastAttended}" for="lastAttended">
                     <h:inputText value="#{person.lastAttended}" id="lastAttended">
                     <f:convertDateTime type="date" dateStyle="short"/>
                     </h:inputText>
                     <span class="rvgMessage"><h:message for="lastAttended"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_created}" for="created">
                     <h:inputText value="#{person.created}" id="created">
                     <f:convertDateTime type="date" dateStyle="short"/>
                     </h:inputText>
                     <span class="rvgMessage"><h:message for="created"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_updated}" for="updated">
                     <h:inputText value="#{person.updated}" id="updated">
                     <f:convertDateTime type="date" dateStyle="short"/>
                     </h:inputText>
                     <span class="rvgMessage"><h:message for="updated"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_vcall}" for="vcall">
                     <h:inputText value="#{person.vcall}" id="vcall"/>
                     <span class="rvgMessage"><h:message for="vcall"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_vhouseCall}" for="vhouseCall">
                     <h:inputText value="#{person.vhouseCall}" id="vhouseCall"/>
                     <span class="rvgMessage"><h:message for="vhouseCall"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_team}" for="team">
                     <h:inputText value="#{person.team}" id="team"/>
                     <span class="rvgMessage"><h:message for="team"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_photoFile}" for="photoFile">
                     <h:inputText value="#{person.photoFile}" id="photoFile"/>
                     <span class="rvgMessage"><h:message for="photoFile"/></span>
                     </h:outputLabel>
                     <h:outputLabel value="#{msg.Person_uniqueId}" for="uniqueId">
                     <h:inputText value="#{person.uniqueId}" id="uniqueId"/>
                     <span class="rvgMessage"><h:message for="uniqueId"/></span>
                     </h:outputLabel>
                     </span>
                    
                    
                    
                     <span class="rvgActions">
                     <h:commandButton type="submit" value="#{msg.Create}" action="#{roomService.addNewPerson}"/>
                     </span>
                    
                     </fieldset>
                     </div>
                    
                     </h:form>
                    
                     </body>
                     </f:view>
                    </html>
                    
                    


                    Person.java

                    package testSeam;
                    
                    // Generated Sep 23, 2006 1:30:00 PM by Hibernate Tools 3.2.0.beta7
                    
                    import java.util.Date;
                    import javax.persistence.Column;
                    import javax.persistence.Entity;
                    import javax.persistence.Id;
                    import javax.persistence.Table;
                    import javax.persistence.OneToOne;
                    import javax.persistence.ManyToOne;
                    import javax.persistence.JoinColumn;
                    import javax.persistence.GeneratedValue;
                    
                    import org.jboss.seam.annotations.Scope;
                    import org.jboss.seam.annotations.Name;
                    import static org.jboss.seam.ScopeType.SESSION;
                    
                    /**
                     * Person generated by hbm2java
                     */
                    @Entity
                    @Name("person")
                    @Scope(SESSION)
                    @Table(name = "person", catalog = "checkin", uniqueConstraints = {})
                    public class Person implements java.io.Serializable {
                    
                     // Fields
                    
                     private int id;
                    
                     private Room room;
                    
                     private Organization organization;
                    
                     private String firstName;
                    
                     private String middleName;
                    
                     private String lastName;
                    
                     private String address1;
                    
                     private String city;
                    
                     private String state;
                    
                     private String zip;
                    
                     private String email;
                    
                     private Date birthday;
                    
                     private Long sex;
                    
                     private String homePhone;
                    
                     private String workPhone;
                    
                     private String beeperPhone;
                    
                     private String cellPhone;
                    
                     private String extraPhone;
                    
                     private String extraPhoneMemo;
                    
                     private String school;
                    
                     private String schoolGrade;
                    
                     private String contact;
                    
                     private String parentName;
                    
                     private String comments;
                    
                     private String minsitry;
                    
                     private Character drama;
                    
                     private Character music;
                    
                     private Long status;
                    
                     private Character visitor;
                    
                     private Character mailList;
                    
                     private Character leader;
                    
                     private Date lastAttended;
                    
                     private Date created;
                    
                     private Date updated;
                    
                     private Character vcall;
                    
                     private Character vhouseCall;
                    
                     private String team;
                    
                     private String photoFile;
                    
                     private String uniqueId;
                    
                     // Constructors
                    
                     /** default constructor */
                     public Person() {
                     System.out.println("Person Constructor called");
                     }
                    
                     /** minimal constructor */
                     /*
                     public Person(int id, int roomId, int organizationId, String firstName) {
                     System.out.println("Person Constructor called with 3 parms");
                     this.id = id;
                     this.roomId = roomId;
                     this.organizationId = organizationId;
                     this.firstName = firstName;
                     }
                     */
                    
                     /** full constructor */
                     /*
                     public Person(int id, int roomId, int organizationId, String firstName,
                     String middleName, String lastName, String address1, String city,
                     String state, String zip, String email, Date birthday, Long sex,
                     String homePhone, String workPhone, String beeperPhone,
                     String cellPhone, String extraPhone, String extraPhoneMemo,
                     String school, String schoolGrade, String contact,
                     String parentName, String comments, String minsitry,
                     Character drama, Character music, Long status, Character visitor,
                     Character mailList, Character leader, Date lastAttended,
                     Date created, Date updated, Character vcall, Character vhouseCall,
                     String team, String photoFile, String uniqueId) {
                     System.out.println("Person Constructor called with ALL parms");
                     this.id = id;
                     this.roomId = roomId;
                     this.organizationId = organizationId;
                     this.firstName = firstName;
                     this.middleName = middleName;
                     this.lastName = lastName;
                     this.address1 = address1;
                     this.city = city;
                     this.state = state;
                     this.zip = zip;
                     this.email = email;
                     this.birthday = birthday;
                     this.sex = sex;
                     this.homePhone = homePhone;
                     this.workPhone = workPhone;
                     this.beeperPhone = beeperPhone;
                     this.cellPhone = cellPhone;
                     this.extraPhone = extraPhone;
                     this.extraPhoneMemo = extraPhoneMemo;
                     this.school = school;
                     this.schoolGrade = schoolGrade;
                     this.contact = contact;
                     this.parentName = parentName;
                     this.comments = comments;
                     this.minsitry = minsitry;
                     this.drama = drama;
                     this.music = music;
                     this.status = status;
                     this.visitor = visitor;
                     this.mailList = mailList;
                     this.leader = leader;
                     this.lastAttended = lastAttended;
                     this.created = created;
                     this.updated = updated;
                     this.vcall = vcall;
                     this.vhouseCall = vhouseCall;
                     this.team = team;
                     this.photoFile = photoFile;
                     this.uniqueId = uniqueId;
                     }
                     */
                    
                     // Property accessors
                     @Id
                     @GeneratedValue
                     public int getId() {
                     System.out.println("Person.getId:"+id);
                     return this.id;
                     }
                    
                     public void setId(int id) {
                     System.out.println("Person.setId:"+id);
                     this.id = id;
                     }
                    
                     @ManyToOne(optional=false)
                     @JoinColumn(name="roomId")
                     public Room getRoom() {
                     System.out.println("Person.getRoom:"+room);
                     return this.room;
                     }
                    
                     public void setRoom(Room room) {
                     System.out.println("Person.setRoom:"+room.getId());
                     this.room = room;
                     }
                    
                     @ManyToOne(optional=true)
                     @JoinColumn(name="organizationId")
                     public Organization getOrganization() {
                     System.out.println("Person.getOrganization:"+organization);
                     return organization;
                     }
                    
                     public void setOrganization(Organization organization) {
                     System.out.println("Person.setRoom:"+organization.getId());
                     this.organization = organization;
                     }
                    
                     @Column(name = "firstName", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
                     public String getFirstName() {
                     System.out.println("Person.getFirstName:"+firstName);
                     return this.firstName;
                     }
                    
                     public void setFirstName(String firstName) {
                     System.out.println("Person.setFirstName:"+firstName);
                     this.firstName = firstName;
                     }
                    
                     @Column(name = "middleName", unique = false, nullable = true, insertable = true, updatable = true, length = 20)
                     public String getMiddleName() {
                     System.out.println("Person.getMiddleName:"+middleName);
                     return this.middleName;
                     }
                    
                     public void setMiddleName(String middleName) {
                     System.out.println("Person.setMiddleName:"+middleName);
                     this.middleName = middleName;
                     }
                    
                     @Column(name = "lastName", unique = false, nullable = true, insertable = true, updatable = true, length = 25)
                     public String getLastName() {
                     System.out.println("Person.getLastName:"+lastName);
                     return this.lastName;
                     }
                    
                     public void setLastName(String lastName) {
                     System.out.println("Person.setLastName:"+lastName);
                     this.lastName = lastName;
                     }
                    
                     @Column(name = "Address1", unique = false, nullable = true, insertable = true, updatable = true, length = 90)
                     public String getAddress1() {
                     return this.address1;
                     }
                    
                     public void setAddress1(String address1) {
                     this.address1 = address1;
                     }
                    
                     @Column(name = "City", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
                     public String getCity() {
                     return this.city;
                     }
                    
                     public void setCity(String city) {
                     this.city = city;
                     }
                    
                     @Column(name = "State", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
                     public String getState() {
                     return this.state;
                     }
                    
                     public void setState(String state) {
                     this.state = state;
                     }
                    
                     @Column(name = "Zip", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
                     public String getZip() {
                     return this.zip;
                     }
                    
                     public void setZip(String zip) {
                     this.zip = zip;
                     }
                    
                     @Column(name = "EMail", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
                     public String getEmail() {
                     return this.email;
                     }
                    
                     public void setEmail(String email) {
                     this.email = email;
                     }
                    
                     @Column(name = "birthday", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
                     public Date getBirthday() {
                     return this.birthday;
                     }
                    
                     public void setBirthday(Date birthday) {
                     this.birthday = birthday;
                     }
                    
                     @Column(name = "Sex", unique = false, nullable = true, insertable = true, updatable = true, precision = 10, scale = 0)
                     public Long getSex() {
                     return this.sex;
                     }
                    
                     public void setSex(Long sex) {
                     this.sex = sex;
                     }
                    
                     @Column(name = "HomePhone", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
                     public String getHomePhone() {
                     return this.homePhone;
                     }
                    
                     public void setHomePhone(String homePhone) {
                     this.homePhone = homePhone;
                     }
                    
                     @Column(name = "WorkPhone", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
                     public String getWorkPhone() {
                     return this.workPhone;
                     }
                    
                     public void setWorkPhone(String workPhone) {
                     this.workPhone = workPhone;
                     }
                    
                     @Column(name = "BeeperPhone", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
                     public String getBeeperPhone() {
                     return this.beeperPhone;
                     }
                    
                     public void setBeeperPhone(String beeperPhone) {
                     this.beeperPhone = beeperPhone;
                     }
                    
                     @Column(name = "CellPhone", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
                     public String getCellPhone() {
                     return this.cellPhone;
                     }
                    
                     public void setCellPhone(String cellPhone) {
                     this.cellPhone = cellPhone;
                     }
                    
                     @Column(name = "ExtraPhone", unique = false, nullable = true, insertable = true, updatable = true, length = 15)
                     public String getExtraPhone() {
                     return this.extraPhone;
                     }
                    
                     public void setExtraPhone(String extraPhone) {
                     this.extraPhone = extraPhone;
                     }
                    
                     @Column(name = "ExtraPhoneMemo", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
                     public String getExtraPhoneMemo() {
                     return this.extraPhoneMemo;
                     }
                    
                     public void setExtraPhoneMemo(String extraPhoneMemo) {
                     this.extraPhoneMemo = extraPhoneMemo;
                     }
                    
                     @Column(name = "School", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
                     public String getSchool() {
                     return this.school;
                     }
                    
                     public void setSchool(String school) {
                     this.school = school;
                     }
                    
                     @Column(name = "SchoolGrade", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
                     public String getSchoolGrade() {
                     return this.schoolGrade;
                     }
                    
                     public void setSchoolGrade(String schoolGrade) {
                     this.schoolGrade = schoolGrade;
                     }
                    
                     @Column(name = "Contact", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
                     public String getContact() {
                     return this.contact;
                     }
                    
                     public void setContact(String contact) {
                     this.contact = contact;
                     }
                    
                     @Column(name = "ParentName", unique = false, nullable = true, insertable = true, updatable = true, length = 75)
                     public String getParentName() {
                     return this.parentName;
                     }
                    
                     public void setParentName(String parentName) {
                     this.parentName = parentName;
                     }
                    
                     @Column(name = "Comments", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
                     public String getComments() {
                     return this.comments;
                     }
                    
                     public void setComments(String comments) {
                     this.comments = comments;
                     }
                    
                     @Column(name = "Minsitry", unique = false, nullable = true, insertable = true, updatable = true, length = 60)
                     public String getMinsitry() {
                     return this.minsitry;
                     }
                    
                     public void setMinsitry(String minsitry) {
                     this.minsitry = minsitry;
                     }
                    
                     @Column(name = "Drama", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
                     public Character getDrama() {
                     return this.drama;
                     }
                    
                     public void setDrama(Character drama) {
                     this.drama = drama;
                     }
                    
                     @Column(name = "Music", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
                     public Character getMusic() {
                     return this.music;
                     }
                    
                     public void setMusic(Character music) {
                     this.music = music;
                     }
                    
                     @Column(name = "Status", unique = false, nullable = true, insertable = true, updatable = true, precision = 10, scale = 0)
                     public Long getStatus() {
                     return this.status;
                     }
                    
                     public void setStatus(Long status) {
                     this.status = status;
                     }
                    
                     @Column(name = "Visitor", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
                     public Character getVisitor() {
                     return this.visitor;
                     }
                    
                     public void setVisitor(Character visitor) {
                     this.visitor = visitor;
                     }
                    
                     @Column(name = "Mail_List", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
                     public Character getMailList() {
                     return this.mailList;
                     }
                    
                     public void setMailList(Character mailList) {
                     this.mailList = mailList;
                     }
                    
                     @Column(name = "Leader", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
                     public Character getLeader() {
                     return this.leader;
                     }
                    
                     public void setLeader(Character leader) {
                     this.leader = leader;
                     }
                    
                     @Column(name = "Last_Attended", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
                     public Date getLastAttended() {
                     return this.lastAttended;
                     }
                    
                     public void setLastAttended(Date lastAttended) {
                     this.lastAttended = lastAttended;
                     }
                    
                     @Column(name = "Created", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
                     public Date getCreated() {
                     return this.created;
                     }
                    
                     public void setCreated(Date created) {
                     this.created = created;
                     }
                    
                     @Column(name = "Updated", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
                     public Date getUpdated() {
                     return this.updated;
                     }
                    
                     public void setUpdated(Date updated) {
                     this.updated = updated;
                     }
                    
                     @Column(name = "VCall", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
                     public Character getVcall() {
                     return this.vcall;
                     }
                    
                     public void setVcall(Character vcall) {
                     this.vcall = vcall;
                     }
                    
                     @Column(name = "VHouseCall", unique = false, nullable = true, insertable = true, updatable = true, length = 1)
                     public Character getVhouseCall() {
                     return this.vhouseCall;
                     }
                    
                     public void setVhouseCall(Character vhouseCall) {
                     this.vhouseCall = vhouseCall;
                     }
                    
                     @Column(name = "Team", unique = false, nullable = true, insertable = true, updatable = true, length = 17)
                     public String getTeam() {
                     return this.team;
                     }
                    
                     public void setTeam(String team) {
                     this.team = team;
                     }
                    
                     @Column(name = "PhotoFile", unique = false, nullable = true, insertable = true, updatable = true, length = 75)
                     public String getPhotoFile() {
                     return this.photoFile;
                     }
                    
                     public void setPhotoFile(String photoFile) {
                     this.photoFile = photoFile;
                     }
                    
                     @Column(name = "UniqueID", unique = false, nullable = true, insertable = true, updatable = true, length = 45)
                     public String getUniqueId() {
                     return this.uniqueId;
                     }
                    
                     public void setUniqueId(String uniqueId) {
                     this.uniqueId = uniqueId;
                     }
                    
                    }
                    
                    


                    Room.java

                    package testSeam;
                    
                    // Generated Oct 6, 2006 12:55:26 AM by Hibernate Tools 3.2.0.beta7
                    
                    import javax.persistence.Column;
                    import javax.persistence.Entity;
                    import javax.persistence.Id;
                    import javax.persistence.Table;
                    
                    /**
                     * Room generated by hbm2java
                     */
                    @Entity
                    @Table(name = "room", catalog = "checkin", uniqueConstraints = {})
                    public class Room implements java.io.Serializable {
                    
                     // Fields
                    
                     private int id;
                    
                     private String name;
                    
                     private int organizationId;
                    
                     private int capacity;
                    
                     // Constructors
                    
                     /** default constructor */
                     public Room() {
                     }
                    
                     /** full constructor */
                     public Room(int id, String name, int organizationId, int capacity) {
                     this.id = id;
                     this.name = name;
                     this.organizationId = organizationId;
                     this.capacity = capacity;
                     }
                    
                     // Property accessors
                     @Id
                     @Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true)
                     public int getId() {
                     return this.id;
                     }
                    
                     public void setId(int id) {
                     this.id = id;
                     }
                    
                     @Column(name = "Name", unique = false, nullable = false, insertable = true, updatable = true, length = 50)
                     public String getName() {
                     return this.name;
                     }
                    
                     public void setName(String name) {
                     this.name = name;
                     }
                    
                     @Column(name = "OrganizationID", unique = false, nullable = false, insertable = true, updatable = true)
                     public int getOrganizationId() {
                     return this.organizationId;
                     }
                    
                     public void setOrganizationId(int organizationId) {
                     this.organizationId = organizationId;
                     }
                    
                     @Column(name = "Capacity", unique = false, nullable = false, insertable = true, updatable = true)
                     public int getCapacity() {
                     return this.capacity;
                     }
                    
                     public void setCapacity(int capacity) {
                     this.capacity = capacity;
                     }
                    
                    }
                    
                    


                    Organization.java

                    package testSeam;
                    
                    // Generated Sep 23, 2006 1:30:00 PM by Hibernate Tools 3.2.0.beta7
                    
                    import javax.persistence.Column;
                    import javax.persistence.Entity;
                    import javax.persistence.Id;
                    import javax.persistence.Table;
                    
                    /**
                     * Organization generated by hbm2java
                     */
                    @Entity
                    @Table(name = "organization", catalog = "checkin", uniqueConstraints = {})
                    public class Organization implements java.io.Serializable {
                    
                     // Fields
                    
                     private int id;
                    
                     private String name;
                    
                     private String address1;
                    
                     private String address2;
                    
                     private String city;
                    
                     private String state;
                    
                     private String zip;
                    
                     private String country;
                    
                     private String phone1;
                    
                     private String phone2;
                    
                     private String homepage;
                    
                     // Constructors
                    
                     /** default constructor */
                     public Organization() {
                     }
                    
                     /** full constructor */
                     public Organization(int id, String name, String address1, String address2,
                     String city, String state, String zip, String country,
                     String phone1, String phone2, String homepage) {
                     this.id = id;
                     this.name = name;
                     this.address1 = address1;
                     this.address2 = address2;
                     this.city = city;
                     this.state = state;
                     this.zip = zip;
                     this.country = country;
                     this.phone1 = phone1;
                     this.phone2 = phone2;
                     this.homepage = homepage;
                     }
                    
                     // Property accessors
                     @Id
                     @Column(name = "id", unique = true, nullable = false, insertable = true, updatable = true)
                     public int getId() {
                     return this.id;
                     }
                    
                     public void setId(int id) {
                     this.id = id;
                     }
                    
                     @Column(name = "name", unique = false, nullable = false, insertable = true, updatable = true, length = 100)
                     public String getName() {
                     return this.name;
                     }
                    
                     public void setName(String name) {
                     this.name = name;
                     }
                    
                     @Column(name = "address1", unique = false, nullable = false, insertable = true, updatable = true, length = 100)
                     public String getAddress1() {
                     return this.address1;
                     }
                    
                     public void setAddress1(String address1) {
                     this.address1 = address1;
                     }
                    
                     @Column(name = "address2", unique = false, nullable = false, insertable = true, updatable = true, length = 100)
                     public String getAddress2() {
                     return this.address2;
                     }
                    
                     public void setAddress2(String address2) {
                     this.address2 = address2;
                     }
                    
                     @Column(name = "city", unique = false, nullable = false, insertable = true, updatable = true, length = 45)
                     public String getCity() {
                     return this.city;
                     }
                    
                     public void setCity(String city) {
                     this.city = city;
                     }
                    
                     @Column(name = "state", unique = false, nullable = false, insertable = true, updatable = true, length = 45)
                     public String getState() {
                     return this.state;
                     }
                    
                     public void setState(String state) {
                     this.state = state;
                     }
                    
                     @Column(name = "zip", unique = false, nullable = false, insertable = true, updatable = true, length = 45)
                     public String getZip() {
                     return this.zip;
                     }
                    
                     public void setZip(String zip) {
                     this.zip = zip;
                     }
                    
                     @Column(name = "country", unique = false, nullable = false, insertable = true, updatable = true, length = 45)
                     public String getCountry() {
                     return this.country;
                     }
                    
                     public void setCountry(String country) {
                     this.country = country;
                     }
                    
                     @Column(name = "phone1", unique = false, nullable = false, insertable = true, updatable = true, length = 40)
                     public String getPhone1() {
                     return this.phone1;
                     }
                    
                     public void setPhone1(String phone1) {
                     this.phone1 = phone1;
                     }
                    
                     @Column(name = "phone2", unique = false, nullable = false, insertable = true, updatable = true, length = 40)
                     public String getPhone2() {
                     return this.phone2;
                     }
                    
                     public void setPhone2(String phone2) {
                     this.phone2 = phone2;
                     }
                    
                     @Column(name = "homepage", unique = false, nullable = false, insertable = true, updatable = true, length = 100)
                     public String getHomepage() {
                     return this.homepage;
                     }
                    
                     public void setHomepage(String homepage) {
                     this.homepage = homepage;
                     }
                    }
                    
                    


                    RoomServiceBean.java

                     package testSeam;
                    
                    // Generated Oct 6, 2006 12:55:26 AM by Hibernate Tools 3.2.0.beta7
                    
                    import java.util.ArrayList;
                    import java.util.Iterator;
                    import java.util.Map;
                    import java.util.List;
                    import javax.ejb.Remove;
                    import javax.ejb.Stateless;
                    import javax.ejb.Stateful;
                    import javax.ejb.TransactionAttribute;
                    import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
                    import javax.faces.application.FacesMessage;
                    import javax.faces.context.FacesContext;
                    import javax.faces.model.SelectItem;
                    import javax.interceptor.Interceptors;
                    import javax.persistence.EntityManager;
                    
                    import org.jboss.seam.annotations.Begin;
                    import org.jboss.seam.annotations.Destroy;
                    import org.jboss.seam.annotations.End;
                    import org.jboss.seam.annotations.IfInvalid;
                    import org.jboss.seam.annotations.In;
                    import org.jboss.seam.annotations.Out;
                    import org.jboss.seam.annotations.Name;
                    import org.jboss.seam.annotations.Outcome;
                    import org.jboss.seam.annotations.Logger;
                    import org.jboss.seam.annotations.Factory;
                    
                    import org.jboss.seam.ejb.SeamInterceptor;
                    import org.jboss.seam.log.Log;
                    import org.jboss.seam.selectitems.annotations.SelectItems;
                    
                    import org.hibernate.validator.Valid;
                    
                    @Name("roomService")
                    @Stateless
                    @Interceptors(SeamInterceptor.class)
                    public class RoomServiceBean implements RoomService {
                     @Logger
                     private Log log;
                    
                     @In(create = true)
                     private EntityManager entityManager;
                    
                     private Room room = new Room();
                    
                     @Valid
                     private Person person;
                    
                     private String doneOutcome = "find";
                    
                     @In(required = false)
                     private transient RoomFinder roomFinder;
                    
                     @In(create = true)
                     private transient Map messages;
                    
                     private boolean isNew = true;
                    
                     @SelectItems(label="name", addNoSelectionLabel="Please select a room")
                     private List<Room> rooms;
                    
                     @SelectItems(label="name", addNoSelectionLabel="Please select an organization")
                     private List<Organization> organizations;
                    
                     @TransactionAttribute(NOT_SUPPORTED)
                     public Person getPerson() {
                     System.out.println("PersonEditorBean.getPerson|"+person);
                     return person;
                     }
                    
                     public void setPerson(Person person) {
                     System.out.println("PersonEditorBean.setPerson|"+person);
                     this.person = person;
                     }
                    
                     @TransactionAttribute(NOT_SUPPORTED)
                     public Room getRoom() {
                     return room;
                     }
                    
                     public void setRoom(Room room) {
                     this.room = room;
                     }
                    
                     @TransactionAttribute(NOT_SUPPORTED)
                     public boolean isNew() {
                     return isNew;
                     }
                    
                     public void setNew(boolean isNew) {
                     this.isNew = isNew;
                     }
                    
                     public void setDoneOutcome(String outcome) {
                     doneOutcome = outcome;
                     }
                    
                     @SuppressWarnings("unchecked")
                     @Factory("rooms")
                     public void buildRooms() {
                     log.info("top of buildRooms()");
                     rooms = entityManager.createQuery("select rm from Room rm").getResultList();
                     log.info("Room list has " + rooms.size() + " entries");
                     }
                    
                     @SuppressWarnings("unchecked")
                     @Factory("organizations")
                     public void buildOrganizations() {
                     log.info("top of buildOrganizations()");
                     organizations = entityManager.createQuery("select org from Organization org").getResultList();
                     log.info("Organization list has " + organizations.size() + " entries");
                     }
                    
                     @Begin(join = true)
                     @IfInvalid(outcome = Outcome.REDISPLAY)
                     public String addNewPerson() {
                     log.info("top of RoomServieBean.create()");
                     log.info("person.firstName: "+person.getFirstName());
                    
                     if (entityManager.find(Person.class, person.getId()) != null) {
                     FacesContext.getCurrentInstance().addMessage( null, new FacesMessage(messages.get("Person_id") + " " + messages.get("AlreadyExists")));
                     return null;
                     }
                    
                     entityManager.persist(person);
                     isNew = false;
                     refreshFinder();
                     return "uQuickPersonAdd";
                     }
                    
                     @IfInvalid(outcome = Outcome.REDISPLAY)
                     public String update() {
                     refreshFinder();
                     return null;
                     }
                    
                     @End(ifOutcome = "find")
                     public String delete() {
                     entityManager.remove(room);
                     refreshFinder();
                     return doneOutcome;
                     }
                    
                     @End(ifOutcome = "find")
                     public String done() {
                     if (!isNew)
                     entityManager.refresh(room);
                     return doneOutcome;
                     }
                    
                     private void refreshFinder() {
                     if (roomFinder != null)
                     roomFinder.refresh();
                     }
                    }
                    
                    


                    • 7. Re: Challenge: Simple Example Adding Records With Lookup Dro
                      pmuir

                       

                      "johnurban" wrote:
                      So, some magic is happening between jsf submit and RoomServiceBean.


                      Yes it is :) Check you've configured org.jboss.seam.selectitems.SelectItemsPersistenceConfig -> persistenceUnitJndiName in components.xml - it should be set the same as org.jboss.seam.core.ManagedPersistenceContext -> persistenceUnitJndiName

                      • 8. Re: Challenge: Simple Example Adding Records With Lookup Dro
                        johnurban

                        my components.xml

                        <?xml version="1.0" encoding="utf-8"?>
                        <components>
                         <component name="org.jboss.seam.core.init">
                         <property name="myFacesLifecycleBug">true</property>
                         <property name="jndiPattern">seamapp/#{ejbName}/local</property>
                         </component>
                         <component name="entityManager" class="org.jboss.seam.core.ManagedPersistenceContext">
                         <property name="persistenceUnitJndiName">java:/seamappEntityManagerFactory</property>
                         </component>
                         <component class="org.jboss.seam.selectitems.SelectItemsPersistenceConfig">
                         <property name="persistenceUnitJndiName">java:/selectItemsEntityManagerFactory</property>
                         </component>
                        <!--
                         <component name="org.jboss.seam.core.manager">
                         <property name="conversationTimeout">120000</property>
                         </component>
                        
                         <component class="org.jboss.seam.core.Ejb" installed="false"/>
                         -->
                        </components>
                        
                        


                        • 9. Re: Challenge: Simple Example Adding Records With Lookup Dro
                          johnurban

                          I should also say, that the rooms and organization lookups work fine using the EntityManager from inside RoomServiceBean. But it appears that the the jsf is trying to access the EntityManager from somewhere other than than RoomServiceBean, because I get no System.out messages once I click on the roomService.addNewPerson button.

                          • 10. Re: Challenge: Simple Example Adding Records With Lookup Dro
                            pmuir

                             

                            "petemuir" wrote:
                            Check you've configured org.jboss.seam.selectitems.SelectItemsPersistenceConfig -> persistenceUnitJndiName in components.xml - it should be set the same as org.jboss.seam.core.ManagedPersistenceContext -> persistenceUnitJndiName


                            <component class="org.jboss.seam.selectitems.SelectItemsPersistenceConfig">
                             <property name="persistenceUnitJndiName">java:/seamappEntityManagerFactory</property>
                             </component>


                            This is explained on the wiki and in the readme.

                            • 11. Re: Challenge: Simple Example Adding Records With Lookup Dro
                              johnurban

                              Thank you for the extra eyes. I'm beginning to wish I had NOT started w/ the hibernate generated code for this particular app. Configuration seems to be a big part of this.

                              I got past the entitymanager issue, now I'm stuck with the exact same code giving me a Validation error on the jsp. My question:

                              How do I figure out what is NOT getting validated?

                              • 12. Re: Challenge: Simple Example Adding Records With Lookup Dro
                                johnurban

                                Wow, I get to answer my own question for a change:

                                The validation error was resolved when I read the example by Mr. Muir. I had to override the equals method:

                                 @Override
                                 public boolean equals(Object obj) {
                                 if (!(obj != null && obj instanceof Room))
                                 return false;
                                 Room rm = (Room) obj;
                                
                                 if (this.id.equals(rm.id))
                                 return true;
                                
                                 return false;
                                 }
                                


                                The next problem I got I fixed reading another forum post.. changing the entityManager.persist to entitymanager.merge

                                I GOT THE Record to ADD!!

                                • 13. Re: Challenge: Simple Example Adding Records With Lookup Dro

                                  I#ve got the same problem. The real differences between your and my version is the usage of the EntityConverter and the @SelectItems.

                                  Could you please tell me what you did to get it working?

                                  Do I have to use @SelectItems and/or the EntityConverter or does it also work with a "pure" Seam?

                                  • 14. Re: Challenge: Simple Example Adding Records With Lookup Dro
                                    pmuir

                                    Well there are really two approaches:

                                    1) Traditional JSF - write a converter and outject a List - this is described on the wiki http://wiki.jboss.org/wiki/Wiki.jsp?page=SelectItems

                                    2) Use the SeamSelectItems package - an old version of which is being discussed here

                                    1 2 3 Previous Next