[jboss-user] [JBoss Seam] - Adding/Persisting A Record Problem...

johnurban do-not-reply at jboss.com
Fri Oct 20 09:47:21 EDT 2006


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.

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

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



More information about the jboss-user mailing list