Here is what I have so far: Here is my xhtml file:
| | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | <ui:composition xmlns="http://www.w3.org/1999/xhtml" | xmlns:ui="http://java.sun.com/jsf/facelets" | xmlns:h="http://java.sun.com/jsf/html" | xmlns:f="http://java.sun.com/jsf/core" | xmlns:s="http://jboss.com/products/seam/taglib" | xmlns:a4j="http://richfaces.org/a4j" | xmlns:rich="http://richfaces.org/rich" | template="template.xhtml"> | | <!-- content --> | | <ui:define name="content"> | <h:form> | <div id="mainHeader"><h1>Project List</h1></div> | <div id="mainContent"> | <div id="sectionHeader"><h2>About The Person</h2></div> | <div id="projectLeftSide"> | <div id="entry"> | <label>Person Name:</label> | <div class="input"> | <h:inputText id="personName" value="#{person.personName}" /> | </div> | </div> | | <div id="entry"> | <label>Zip Code:</label> | <div class="input"> | <h:selectOneMenu value="#{person.zipCodes}" id="zipCodes"> | <s:selectItems value="#{zipCodes.resultList}" var="zip" label="#{zip.zipcodeNumber}" /> | <s:convertEntity /> | </h:selectOneMenu> | </div> | </div> | </div> | | <div id="buttonSection"> | <div class="button"> | <h:commandButton value="Add" action="#{thePerson.addNewPerson}"/> | </div> | <div class="button"> | <s:button id="cancelButton" value="Cancel" view="/main.xhtml" /> | </div> | </div> | </div> | <div id="mainFooter"> </div> | </h:form> | | </ui:define> | </ui:composition> | | In bold red is what I want to do, just don't know how the backend should be coded... Here is my components.xml file: | <?xml version="1.0" encoding="UTF-8"?> | <components xmlns="http://jboss.com/products/seam/components" | xmlns:core="http://jboss.com/products/seam/core" | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | xsi:schemaLocation= | "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd | | http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd"> | | <core:init jndi-pattern="@jndiPattern@" debug="true"/> | | <core:manager conversation-timeout="120000" | concurrent-request-timeout="500" | conversation-id-parameter="cid"/> | | | </components> | Here is my persistence.xml file: | <?xml version="1.0" encoding="UTF-8"?> | <persistence xmlns="http://java.sun.com/xml/ns/persistence" | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" | version="1.0"> | | <persistence-unit name="myDatabase"> | <provider>org.hibernate.ejb.HibernatePersistence</provider> | <jta-data-source>java:/OracleDS</jta-data-source> | <properties> | <property name="hibernate.hbm2ddl.auto" value="none"/> | </properties> | </persistence-unit> | </persistence> | Here is my main entity bean: | package com.org.selectonemenu.entity; | | import javax.persistence.Column; | import javax.persistence.Entity; | import javax.persistence.FetchType; | import javax.persistence.Id; | import javax.persistence.JoinColumn; | import javax.persistence.ManyToOne; | import javax.persistence.Table; | | import org.jboss.seam.annotations.Name; | | @Entity | @Name("person") | @Table(name = "PERSON") | public class Person implements java.io.Serializable { | | private long personId; | private ZipCodes zipCodes; | private String personName; | | public Person() { | } | | public Person(long personId) { | this.personId = personId; | } | | public Person(long personId, ZipCodes zipCodes, String personName) { | this.personId = personId; | this.zipCodes = zipCodes; | this.personName = personName; | } | | @Id | @Column(name = "PERSON_ID", unique = true, nullable = false, precision = 12, scale = 0) | public long getPersonId() { | return this.personId; | } | | public void setPersonId(long personId) { | this.personId = personId; | } | | @ManyToOne(fetch = FetchType.LAZY) | @JoinColumn(name = "ZIPCODE_ID") | public ZipCodes getZipCodes() { | return this.zipCodes; | } | | public void setZipCodes(ZipCodes zipCodes) { | this.zipCodes = zipCodes; | } | | @Column(name = "PERSON_NAME", length = 100) | public String getPersonName() { | return this.personName; | } | | public void setPersonName(String personName) { | this.personName = personName; | } | | } | Here is the lookup Entity Bean: | package com.org.selectonemenu.entity; | | import java.util.HashSet; | import java.util.Set; | import javax.persistence.CascadeType; | import javax.persistence.Column; | import javax.persistence.Entity; | import javax.persistence.FetchType; | import javax.persistence.Id; | import javax.persistence.OneToMany; | import javax.persistence.Table; | | import org.jboss.seam.annotations.Name; | | @Entity | @Name("zipcodes") | @Table(name = "ZIP_CODES") | public class ZipCodes implements java.io.Serializable { | | private long zipcodeId; | private String zipcodeNumber; | private Set<Person> persons = new HashSet<Person>(0); | | public ZipCodes() { | } | | public ZipCodes(long zipcodeId) { | this.zipcodeId = zipcodeId; | } | | public ZipCodes(long zipcodeId, String zipcodeNumber, Set<Person> persons) { | this.zipcodeId = zipcodeId; | this.zipcodeNumber = zipcodeNumber; | this.persons = persons; | } | | @Id | @Column(name = "ZIPCODE_ID", unique = true, nullable = false, precision = 12, scale = 0) | public long getZipcodeId() { | return this.zipcodeId; | } | | public void setZipcodeId(long zipcodeId) { | this.zipcodeId = zipcodeId; | } | | @Column(name = "ZIPCODE_NUMBER", length = 50) | public String getZipcodeNumber() { | return this.zipcodeNumber; | } | | public void setZipcodeNumber(String zipcodeNumber) { | this.zipcodeNumber = zipcodeNumber; | } | | @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "zipCodes") | public Set<Person> getPersons() { | return this.persons; | } | | public void setPersons(Set<Person> persons) { | this.persons = persons; | } | | } | And finally here is my sfsb that I use to persist to the database: | package com.org.selectonemenu.sfsb; | | import javax.ejb.Remove; | import javax.ejb.Stateful; | import javax.persistence.EntityManager; | import javax.persistence.PersistenceContext; | | import org.jboss.seam.ScopeType; | import org.jboss.seam.annotations.Destroy; | import org.jboss.seam.annotations.In; | import org.jboss.seam.annotations.Name; | import org.jboss.seam.annotations.Out; | import org.jboss.seam.annotations.Scope; | | import com.org.selectonemenu.entity.Person; | import com.org.selectonemenu.interfaces.PersonMgr; | | @Stateful | @Name("thePerson") | @Scope(ScopeType.SESSION) | public class PersonSFSB implements PersonMgr { | | @PersistenceContext | private EntityManager entityManager; | | @In(required = false) | @Out(required = false) | private Person person; | | | public void addNewPerson() { | Person addPerson = person; | | addPerson.setZipCodes(person.getZipCodes()); | addPerson.setPersonName(person.getPersonName()); | | entityManager.persist(addPerson); | | } | | @Destroy | @Remove | public void destroy() { | } | } | So out of these files what do I need to change and what files do I need to add...As I mentioned before I am using the latest Seam Snapshot...I'm on JBoss Server 4.2.1 Thank you for any help that anyone could provide to me. Blue View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4096339#4096339 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4096339 _______________________________________________ jboss-user mailing list [email protected] https://lists.jboss.org/mailman/listinfo/jboss-user
