1 2 Previous Next 16 Replies Latest reply on Nov 13, 2006 2:24 PM by Arley Maia

    Adding/Persisting A Record Problem...

    johnurban Newbie

      I have taken the Seam generated code and created a new jsp page that is similar to the original generated JSF's for the editPerson.jsp. It is called uQuickPersonAdd.jsp. It populates a dropdown with room data and needs to add/persist this record to the person table. My problem is, the PersonEditorBean.create() method never gets called. No exceptions, no validation errors. What is the trick to get the jsp to call the create method?

      jsf code:

      <%@ 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:selectOneMenu value="#{roomFinder.example}" converter="org.jboss.seam.EntityConverter">
       <f:selectItems value="#{roomListByOrganization}" />
       </h:selectOneMenu>
      
       <h:outputLabel value="#{msg.Person_firstName}" for="firstName">
       <h:inputText value="#{personEditor.instance}" 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}" 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}" id="birthday">
       <f:convertDateTime type="date" dateStyle="short"/>
       </h:inputText>
       <span class="rvgMessage"><h:message for="birthday"/></span>
       </h:outputLabel>
      
       <span class="rvgActions">
       <h:commandButton type="submit" value="#{msg.Create}" action="#{personEditor.create}"/>
       </span>
      
       </fieldset>
       </div>
      
       </h:form>
      
       </body>
       </f:view>
      </html>
      


      EJB:

      package testSeam;
      
      // Generated Sep 23, 2006 1:30:01 PM by Hibernate Tools 3.2.0.beta7
      
      import java.util.Map;
      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.interceptor.Interceptors;
      import javax.persistence.EntityManager;
      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.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;
      
      @Name("personEditor")
      @Stateful
      @Scope(ScopeType.SESSION)
      @Interceptors(SeamInterceptor.class)
      public class PersonEditorBean implements PersonEditor {
      
       @In(create = true)
       private EntityManager entityManager;
      
       @Valid
       private Person instance = new Person();
      
       private boolean isNew = true;
      
       private String doneOutcome = "find";
      
       @TransactionAttribute(NOT_SUPPORTED)
       public Person getInstance() {
       return instance;
       }
      
       public void setInstance(Person instance) {
       this.instance = instance;
       }
      
       @TransactionAttribute(NOT_SUPPORTED)
       public boolean 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;
      
       @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() {
       }
      
      }
      
      


      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;
      
      /**
       * Person generated by hbm2java
       */
      @Entity
      @Table(name = "person", catalog = "checkin", uniqueConstraints = {})
      public class Person implements java.io.Serializable {
      
       // Fields
      
       private int id;
      
       private int roomId;
      
       private int organizationId;
      
       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() {
       }
      
       /** minimal constructor */
       public Person(int id, int roomId, int organizationId, String firstName) {
       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) {
       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 int getRoomId() {
       return this.roomId;
       }
      
       public void setRoomId(int roomId) {
       this.roomId = roomId;
       }
      
       @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 = "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;
       }
      
      }
      


      Must I put an entery in either pages.xml or faces-config.xml? I didn't see that for the generated code.

        • 1. Re: Adding/Persisting A Record Problem...
          johnurban Newbie

          Just wondering..

          Is this a common problem or a "this guy doesn't know what the heck he is doing" problem.

          I'm pretty certain its the later. I'll go back and start with an example from scratch and follow it through... then post my findings.

          • 2. Re: Adding/Persisting A Record Problem...
            johnurban Newbie

            Getting closer on this. Narrowed it down to the fact that it doesn't matter what I put for the action on the submit button, it just won't call my EJB's create method.

            Here is what I would expect to work:

            <h:commandButton type="submit" value="#{msg.Create}" action="#{personEditor.create}" rendered="#{personEditor.new}"/>
            


            The create method never gets called. Just for grins, I tried this:

            <h:commandButton type="submit" value="#{msg.Create}" action="#{personEditor.poo}" rendered="#{personEditor.new}"/>
            


            Putting this in did NOT throw any exceptions are cause any problems. In fact, it behaved the exact same way as the personEditor.create.

            • 3. Re: Adding/Persisting A Record Problem...
              Andy Dennis Newbie

              Try changing it to a commandLink and see what happens.
              Andy.

              • 4. Re: Adding/Persisting A Record Problem...
                johnurban Newbie

                Getting closer. I removed the room dropdown lookup logic from the jsp and it complianed about calling personEdtor.poo. I changed it back to personEditor.create and it added the record. So it appears there is something that occurs when the dropdown room lookup logic is inserted in the jsf:

                JSF:

                 <h:selectOneMenu value="#{roomFinder.example}" converter="org.jboss.seam.EntityConverter">
                 <f:selectItems value="#{roomListByOrganization}" />
                 </h:selectOneMenu>
                
                


                RoomFinderBean

                package testSeam;
                
                // Generated Oct 6, 2006 12:55:26 AM by Hibernate Tools 3.2.0.beta7
                
                import java.util.HashMap;
                import java.util.List;
                import java.util.ArrayList;
                import java.util.Iterator;
                import java.util.Map;
                import java.util.Map.Entry;
                import java.util.TreeMap;
                import javax.ejb.Remove;
                import javax.ejb.Stateful;
                import javax.interceptor.Interceptors;
                import javax.persistence.EntityManager;
                import javax.persistence.Query;
                import javax.faces.component.UISelectItems;
                import javax.faces.model.SelectItem;
                import org.jboss.seam.ScopeType;
                import org.jboss.seam.annotations.Destroy;
                import org.jboss.seam.annotations.In;
                import org.jboss.seam.annotations.Out;
                import org.jboss.seam.annotations.Name;
                import org.jboss.seam.annotations.RequestParameter;
                import org.jboss.seam.annotations.Scope;
                import org.jboss.seam.annotations.Factory;
                
                import org.jboss.seam.selectitems.annotations.*;
                
                import org.jboss.seam.annotations.datamodel.DataModel;
                import org.jboss.seam.annotations.datamodel.DataModelSelection;
                import org.jboss.seam.ejb.SeamInterceptor;
                
                @Name("roomFinder")
                @Stateful
                @Scope(ScopeType.SESSION)
                @Interceptors(SeamInterceptor.class)
                public class RoomFinderBean implements RoomFinder {
                
                 @Out
                 private Room example = new Room();
                
                 public Room getExample() {
                 return example;
                 }
                
                 @In(required=false)
                 private Login login;
                
                 private int pageNumber = 0;
                 private int pageSize = 25;
                
                 public void setPageSize(int size) {
                 pageSize = size;
                 }
                
                 public int getPageSize() {
                 return pageSize;
                 }
                
                 public boolean isPreviousPage() {
                 return roomList != null && pageNumber > 0;
                 }
                
                 public boolean isNextPage() {
                 return roomList != null && roomList.size() == pageSize;
                 }
                
                 @DataModel
                 private List<Room> roomList;
                
                 // @Out
                 // @SelectItems(valueStrategy=SelectItems.Strategy.OBJECT, labelMethod="getname")
                 // private List<Room> roomListByOrganization;
                 @Out
                 @SelectItems(label="name")
                 private List<Room> roomListByOrganization;
                
                 @DataModelSelection
                 private Room selectedRoom;
                
                 @In(create = true)
                 private EntityManager entityManager;
                
                 private void executeQuery() {
                 Map<String, Object> parameters = new HashMap<String, Object>();
                 StringBuffer queryString = new StringBuffer();
                 if (example.getId() != 0) {
                 queryString.append(" and room.id = :id");
                 parameters.put("id", example.getId());
                 }
                 if (example.getName() != null && example.getName().length() > 0) {
                 queryString.append(" and room.name like :name");
                 parameters.put("name", '%' + example.getName() + '%');
                 }
                 if (example.getOrganizationId() != 0) {
                 queryString.append(" and room.organizationId = :organizationId");
                 parameters.put("organizationId", example.getOrganizationId());
                 }
                 if (example.getCapacity() != 0) {
                 queryString.append(" and room.capacity = :capacity");
                 parameters.put("capacity", example.getCapacity());
                 }
                 if (queryString.length() == 0) {
                 queryString.append("select room from Room room");
                 } else {
                 queryString.delete(0, 4).insert(0,
                 "select room from Room room where");
                 }
                
                 if (order != null) {
                 queryString.append(" order by room.").append(order);
                 if (descending)
                 queryString.append(" desc");
                 }
                
                 Query query = entityManager.createQuery(queryString.toString());
                 for (Entry<String, Object> param : parameters.entrySet()) {
                 query.setParameter(param.getKey(), param.getValue());
                 }
                
                 roomList = (List<Room>) query.setMaxResults(pageSize).setFirstResult(
                 pageSize * pageNumber).getResultList();
                 }
                
                 @SuppressWarnings("unchecked")
                 @Factory("roomListByOrganization")
                 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");
                 }
                
                 if (order != null) {
                 queryString.append(" order by room.").append(order);
                 if (descending)
                 queryString.append(" desc");
                 }
                
                 Query query = entityManager.createQuery(queryString.toString());
                 for (Entry<String, Object> param : parameters.entrySet()) {
                 query.setParameter(param.getKey(), param.getValue());
                 }
                 roomListByOrganization = 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;
                 }
                
                 public String findFirstPage() {
                 pageNumber = 0;
                 executeQuery();
                 return null;
                 }
                
                 public String findNextPage() {
                 pageNumber++;
                 executeQuery();
                 return null;
                 }
                
                 public String findPreviousPage() {
                 pageNumber--;
                 executeQuery();
                 return null;
                 }
                
                 public void refresh() {
                 if (roomList != null)
                 executeQuery();
                 }
                
                 public String clear() {
                 roomList = null;
                 example = new Room();
                 return null;
                 }
                
                 public Room getSelection() {
                 return entityManager.merge(selectedRoom);
                 }
                
                 @Destroy
                 @Remove
                 public void destroy() {
                 }
                
                 private String order;
                
                 private boolean descending = false;
                
                 @RequestParameter
                 private String orderBy;
                
                 public String reorder() {
                 if (orderBy.equals(order)) {
                 descending = !descending;
                 } else {
                 descending = false;
                 }
                 order = orderBy;
                 executeQuery();
                 return null;
                 }
                
                }
                


                What am I missing here?

                • 5. Re: Adding/Persisting A Record Problem...
                  johnurban Newbie

                  Sorry Andy, I did not see your post until after I replied with the RoomFinderBean logic. I did go ahead and change it to a commandlink and that did now work either. The personEditor.create method just will not get called.

                  • 6. Re: Adding/Persisting A Record Problem...
                    johnurban Newbie

                     


                    I did go ahead and change it to a commandlink and that did now work either.


                    Should have said:

                    I did go ahead and change it to a commandlink and that did NOT work either.

                    • 7. Re: Adding/Persisting A Record Problem...
                      Andy Dennis Newbie

                      No worries- I'm working with Portal aswell, which adds its own flavour of problems. I have a similar issue, but ok with a commandLink. If I can get this lot working with Portal, it'll be a really cool solution!

                      • 8. Re: Adding/Persisting A Record Problem...
                        johnurban Newbie

                        Ok... If I remove my room lookup dropdown control from the jsp:

                         <h:selectOneMenu id="roomId" value="#{roomFinder.example}" converter="org.jboss.seam.EntityConverter">
                         <f:selectItems value="#{roomListByOrganization}" />
                         </h:selectOneMenu>
                        


                        ... everything works.. the create personEditor.create method works fine. The instant I add the selectOneMenu that looks up the rooms, personEditor stops getting called. Is this a probelm with my understanding of Seam or is it a JSF or Seam bug?

                        This seems like a very common thing that must be done over and over when developing web sites. Is there an example that show how to do this correctly?

                        • 9. Re: Adding/Persisting A Record Problem...
                          Pete Muir Master

                          So (point 2 is the key)

                          1) You presumably don't get any exceptions

                          2) What does <h:messages /> give for the dropdown box. You've probably hit a conversion error. (You have <h:messages globalOnly="true" /> but none for the h:selectOneMenu)

                          3) Try adding a public void setExample(Room example) {...} method - how else can the roomFinder.example get updated?!

                          4) You don't want @Out and @SelectItems on the same outjection as @SelectItems does an outjection itself (having wrapped the list you provide in a list of SelectItem)

                          5) In the @Factory method for roomListByOrganisation you are setting List to be a List - this is wrong. Just set it to be a list of Room as you do about 2/3rds of the way down the method.

                          • 10. Re: Adding/Persisting A Record Problem...
                            johnurban Newbie

                             

                            1) You presumably don't get any exceptions


                            Correct. I'm probably presumming too much. Something is happening that I'm not seeing. I do not see any exceptions.

                            2) What does <h:messages /> give for the dropdown box. You've probably hit a conversion error. (You have <h:messages globalOnly="true" /> but none for the h:selectOneMenu)


                            I think my problem is complex. First of all the code that I am working with was generated using the hibernate code generation tool(This is a good thing). Second, I am taking the generated PersonEditorBean/jsp and trimming it to just a few fields(a quick add). Third, the roomId, needs to be a lookup/dropdown against the room table. So, how the heck do you do this using seam? Fourth, if you say add an h:messages to the dropdown, what do I name the <h:message for="???? this name ????"/>.

                            3)Try adding a public void setExample(Room example) {...} method - how else can the roomFinder.example get updated?!


                            When I click the create button, I simply need to add a new Person record, calling the PersonEditor.create() method with the roomID, take from the room dropdown. Why do I need to go update the RoomFinder bean with that value?

                            4) You don't want @Out and @SelectItems on the same outjection as @SelectItems does an outjection itself (having wrapped the list you provide in a list of SelectItem)


                            If I remove the @Out, I get this:


                            21:25:29,264 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
                            java.lang.IllegalArgumentException: Value binding '#{roomListByOrganization}'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: _id79]} 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:3155)
                            at org.apache.jsp.uQuickPersonAdd_jsp._jspx_meth_h_form_0(uQuickPersonAdd_jsp.java:450)
                            at org.apache.jsp.uQuickPersonAdd_jsp._jspx_meth_f_view_0(uQuickPersonAdd_jsp.java:196)
                            at org.apache.jsp.uQuickPersonAdd_jsp._jspService(uQuickPersonAdd_jsp.java:104)
                            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)
                            21:25:29,265 ERROR [SeamExceptionFilter] uncaught exception handled by Seam
                            javax.servlet.ServletException: Value binding '#{roomListByOrganization}'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: _id79]} 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)
                            21:25:29,266 INFO [SeamExceptionFilter] killing transaction
                            21:25:29,270 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
                            javax.faces.FacesException: Value binding '#{roomListByOrganization}'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: _id79]} 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 '#{roomListByOrganization}'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: _id79]} 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



                            5) In the @Factory method for roomListByOrganisation you are setting List to be a List - this is wrong. Just set it to be a list of Room as you do about 2/3rds of the way down the method.


                            If I send back a list as a List of Room objects, I get this:

                            "Does not reference an Object of type SelectItem, SelectItem[], Collection or Map but of type : null"


                            Thus my reason for turning them into SelectedItem objects.


                            • 11. Re: Adding/Persisting A Record Problem...
                              Pete Muir Master

                               

                              "johnurban" wrote:
                              2) What does <h:messages /> give for the dropdown box. You've probably hit a conversion error. (You have <h:messages globalOnly="true" /> but none for the h:selectOneMenu)


                              Fourth, if you say add an h:messages to the dropdown, what do I name the <h:message for="???? this name ????"/>.


                              <h:selectOneMenu value="#{roomFinder.example}" converter="org.jboss.seam.EntityConverter" id="example">
                               <f:selectItems value="#{roomListByOrganization}" />
                              </h:selectOneMenu>
                              <h:message for="example" />


                              3)Try adding a public void setExample(Room example) {...} method - how else can the roomFinder.example get updated?!


                              When I click the create button, I simply need to add a new Person record, calling the PersonEditor.create() method with the roomID, take from the room dropdown. Why do I need to go update the RoomFinder bean with that value?


                              Well JSF will try to set the value of any compnents on the page including roomFinder.example. Remember selectOneMenus are input components not output.

                              4) You don't want @Out and @SelectItems on the same outjection as @SelectItems does an outjection itself (having wrapped the list you provide in a list of SelectItem)


                              If I remove the @Out, I get this:


                              I'm concerned about the fact that you are outjecting the list of rooms into the session. Try removing the @Out, setting roomListByOrganisation as a List and but a breakpoint on the @Factory method and see when it is run and what the java variable roomListByOrganisation is set to after the Factory method has run - check that you aren't outjecting null!

                              • 12. Re: Adding/Persisting A Record Problem...
                                johnurban Newbie

                                I did as you suggested and made a very simple example. Now I get this exception:

                                "does not contain Objects of type SelectItem"

                                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:selectOneMenu 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="#{roomService.create}" rendered="#{roomService.new}"/>
                                 </span>
                                
                                 </fieldset>
                                 </div>
                                
                                 </h:form>
                                
                                 </body>
                                 </f:view>
                                </html>
                                


                                RoomService.java

                                package testSeam;
                                
                                // Generated Oct 6, 2006 12:55:26 AM by Hibernate Tools 3.2.0.beta7
                                
                                import javax.ejb.Local;
                                
                                @Local
                                public interface RoomService {
                                 public boolean isNew();
                                
                                 public void setNew(boolean isNew);
                                
                                 public Room getRoom();
                                
                                 public void setRoom(Room room);
                                
                                 public void setDoneOutcome(String outcome);
                                
                                 public String update();
                                
                                 public String delete();
                                
                                 public String create();
                                
                                 public String done();
                                
                                 public void buildRooms();
                                }
                                
                                


                                RoomServiceBean.java

                                package testSeam;
                                
                                // Generated Oct 6, 2006 12:55:26 AM by Hibernate Tools 3.2.0.beta7
                                
                                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.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;
                                
                                 @Valid
                                 private Room room = new Room();
                                
                                 private String doneOutcome = "find";
                                
                                 @In(required = false)
                                 private transient RoomFinder roomFinder;
                                
                                 @In(create = true)
                                 private transient Map messages;
                                
                                 private boolean isNew = true;
                                
                                 @SelectItems(label="description", addNoSelectionLabel="Please select a room")
                                 private List<Room> rooms;
                                
                                 @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() {
                                 rooms = entityManager.createQuery("select rm from Room rm").getResultList();
                                 log.info("Room list has " + rooms.size() + " entries");
                                 }
                                
                                 @Begin(join = true)
                                 @IfInvalid(outcome = Outcome.REDISPLAY)
                                 public String create() {
                                 if (entityManager.find(Room.class, room.getId()) != null) {
                                 FacesContext.getCurrentInstance().addMessage(
                                 null,
                                 new FacesMessage(messages.get("Room_id") + " "
                                 + messages.get("AlreadyExists")));
                                 return null;
                                 }
                                 entityManager.persist(room);
                                 isNew = false;
                                 refreshFinder();
                                 return "editRoom";
                                 }
                                
                                 @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();
                                 }
                                }
                                
                                


                                Here is the full exception trace:

                                22:06:30,155 INFO [RoomServiceBean] Room list has 3 entries
                                22:06:30,162 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
                                java.lang.IllegalArgumentException: Collection referenced by UISelectItems with binding '#{rooms}' and 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: _id5][Class: javax.faces.component.UISelectItems,Id: _id6]} does not contain Objects of type SelectItem
                                 at org.apache.myfaces.util.SelectItemsIterator.next(SelectItemsIterator.java:182)
                                 at org.apache.myfaces.renderkit.RendererUtils.internalGetSelectItemList(RendererUtils.java:487)
                                 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:363)
                                 at org.apache.jsp.uQuickPersonAdd_jsp._jspx_meth_h_form_0(uQuickPersonAdd_jsp.java:284)
                                 at org.apache.jsp.uQuickPersonAdd_jsp._jspx_meth_f_view_0(uQuickPersonAdd_jsp.java:179)
                                 at org.apache.jsp.uQuickPersonAdd_jsp._jspService(uQuickPersonAdd_jsp.java:87)
                                 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)
                                22:06:30,207 ERROR [SeamExceptionFilter] uncaught exception handled by Seam
                                javax.servlet.ServletException: Collection referenced by UISelectItems with binding '#{rooms}' and 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: _id5][Class: javax.faces.component.UISelectItems,Id: _id6]} does not contain Objects of type SelectItem
                                 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)
                                22:06:30,230 INFO [SeamExceptionFilter] killing transaction
                                22:06:30,257 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
                                javax.faces.FacesException: Collection referenced by UISelectItems with binding '#{rooms}' and 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: _id5][Class: javax.faces.component.UISelectItems,Id: _id6]} does not contain Objects of type SelectItem
                                 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: Collection referenced by UISelectItems with binding '#{rooms}' and 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: _id5][Class: javax.faces.component.UISelectItems,Id: _id6]} does not contain Objects of type SelectItem
                                 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
                                



                                I'm beginning to wonder if I'll ever get this going. This should be a very simple screen. Does it get easier? I'm getting super discouraged learning Seam. I believe it offers much.. but I need encouragement.

                                • 13. Re: Adding/Persisting A Record Problem...
                                  johnurban Newbie

                                  I need a JBoss Seam mentor/teacher/expert to help me meet a Nov 1 deadline. I contacted JBoss and they do not yet have consulting services for Seam. What are my options? I thnk they can get me up to speed over a Skype connection in about 2 hours.

                                  urban.john@gmail.com

                                  • 14. Re: Adding/Persisting A Record Problem...
                                    Pete Muir Master

                                    If you can send me the code up above as a simple buildable, deployable example then I can see if I can spot the problem.

                                    peter at bleepbleep dot org dot uk

                                    1 2 Previous Next