I realize that this is probably a n00b mistake and if it were a snake it prob'ly woulda bit me, but I hope an answer to this will help others too. I've spent a couple of days on this but cannot see what's wrong; I tried to search for similar issues but didn't find anything and I don't see what's wrong with my example compared to the examples. I've got an abstracted example here, I hope it's not too long to post, but it should be complete.
I have a stateful session bean with scope defaulting to conversation that is backing a page with a couple of <h:inputText> fields that are bound to a couple of non-required bijected values, one being a String, the other a property of an entity bean. I'm using Seam-managed transactions and persistence context. My problems are: 1. For an <h:inputText> whose value is the property of a conversation-scoped context variable managed by my SFSB, why is the property's setter never called with the value typed in? (in bqmgr.xhtml below, typing a new value for the field next to the button labeled "rename quux" and then pressing the button) 2. For an <h:inputText> whose value is a String conversation-scoped context variable managed by my SFSB, why is the variable null (and apparently not injected from the value typed in the form). (in bqmgr.xhtml below, typing in a value for the field next to the button "New Baz Specifying Name" and then pressing the button) I'm using Seam with facelets and EJB3. As always, apologies if I've somehow missed a previous post or piece of RTFM documentation. Thanks, David bqmgr.xhtml | <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | <html | xmlns="http://www.w3.org/1999/xhtml" | xmlns:f="http://java.sun.com/jsf/core" | xmlns:h="http://java.sun.com/jsf/html" | xmlns:s="http://jboss.com/products/seam/taglib" | xmlns:ui="http://java.sun.com/jsf/facelets" | > | <head> | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> | <title>Baz/Quux Manager</title> | </head> | <body> | <div class="errors"><h:messages globalOnly="true"/></div> | <h:form> | <s:link linkStyle="button" value="rename quux" action="#{bqManager.commitQuux}" /> | <h:inputText value="#{quux.name}" /> | </h:form> | <h:form> | <h:outputText value="you have no bazs" | rendered="#{bazList.rowCount == 0}" /> | <h:dataTable var="baz" value="#{bazList}" | rendered="#{bazList.rowCount > 0}"> | <h:column> | <h:outputText value="#{1+bazList.rowIndex}. "/> | <s:link value="delete" action="#{bqManager.deleteBaz}" linkStyle="button"/> | <h:outputText value="#{baz.name}" /> | <br/> | </h:column> | </h:dataTable> | <hr/> | <s:link value="New Baz Specifying Name" action="#{bqManager.createBazSpecifyingName}" linkStyle="button" /> | <h:inputText value="#{namefornewbaz}"/> | <hr/> | <s:link value="New Baz" action="#{bqManager.createBaz}" linkStyle="button" /> | </h:form> | </body> | </html> | BQManagerBean.java | package com.orgmob.play; | | import java.io.Serializable; | import java.util.HashSet; | import java.util.List; | | import javax.ejb.Remove; | import javax.ejb.Stateful; | 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.Factory; | import org.jboss.seam.annotations.In; | import org.jboss.seam.annotations.Logger; | import org.jboss.seam.annotations.Name; | import org.jboss.seam.annotations.Out; | import org.jboss.seam.annotations.datamodel.DataModel; | import org.jboss.seam.annotations.datamodel.DataModelSelection; | import org.jboss.seam.core.FacesMessages; | import org.jboss.seam.log.Log; | | @Stateful | @Name("bqManager") | public class BQManagerBean implements BQManager, Serializable { | | @Logger | private Log log; | | @In(required=false) @Out(required=false) | private Quux quux; | | @In(required=false) @Out(required=false) | private String nameForNewBaz; | | @DataModel(value="bazList") | private List<Baz> bazList; | | @DataModelSelection(value="bazList") | @Out(required=false) | private Baz baz; | | @In(create=true) | private EntityManager orgmobDatabase; | | @In(create=true) | private transient FacesMessages facesMessages; | | @Begin(join=true) | @Factory("quux") | public void findQuuxen() { | log.debug("looking for quux objects..."); | List<Quux> quuxList = (List<Quux>)orgmobDatabase.createQuery( | "from Quux quux order by quux.id asc").getResultList(); | log.debug("found "+quuxList.size()+" quuxs in quuxList: " + quuxList ); | if ( 0 == quuxList.size() ) { | quux = new Quux(); | quux.setName( "quux1" ); | orgmobDatabase.persist( quux ); | orgmobDatabase.flush(); | log.debug( "created: "+quux); | } | else { | quux = quuxList.get(0); | log.debug( "found: "+quux); | } | } | | @Begin(join=true) | @Factory("bazList") | public void findBazs() { | log.debug("looking for baz objects..."); | bazList = (List<Baz>)orgmobDatabase.createQuery( | "from Baz baz order by baz.id asc").getResultList(); | log.debug("found "+bazList.size()+" bazs in bazList: " + bazList ); | } | | @End | public void stop() { | } | | private String newBazname() { | // find a name not currently seen by user; | HashSet<String> baznameS = new HashSet<String>(); | for ( Baz baz : bazList ) { | baznameS.add( baz.getName() ); | } | String baznamePrefix = "baz"; | String bazname; | int attempt = 1; | do { | bazname = baznamePrefix + (attempt++); | } while ( baznameS.contains( bazname ) ); | return bazname; | } | | private void makeABaz( String name ) { | | baz = new Baz(); | baz.setName( name ); | orgmobDatabase.persist( baz ); | orgmobDatabase.flush(); | | log.debug( "created: "+baz); | | findBazs(); // update bazList | } | | public void createBaz() { | makeABaz( newBazname() ); | } | | public void createBazSpecifyingName() { | if ( null == nameForNewBaz ) { | facesMessages.add("BQManagerBean.createBazSpecifyingName(): nameForNewBaz is null!"); | } | makeABaz( nameForNewBaz ); | } | | public void commitQuux() { | if ( null == quux ) { | facesMessages.add("BQManagerBean.commitQuux() called but quux is null!"); | log.error("BQManagerBean.commitQuux() called but quux is null!"); | } | else { | log.debug("BQManagerBean.commitQuux(): pre-merge quux: "+quux); | orgmobDatabase.merge( quux ); | orgmobDatabase.flush(); | } | } | | public void commitBaz() { | if ( null == baz ) { | facesMessages.add("BQManagerBean.commitBaz() called but baz is null!"); | log.error("BQManagerBean.commitBaz() called but baz is null!"); | } | else { | log.debug("BQManagerBean.commitBaz(): pre-merge baz: "+baz); | orgmobDatabase.merge( baz ); | orgmobDatabase.flush(); | } | } | | public void deleteBaz() { | if ( null == baz ) { | facesMessages.add("BQManagerBean.deleteBaz() called but baz is null!"); | log.error("BQManagerBean.deleteBaz() called but baz is null!"); | } | else { | log.debug("removing "+baz+"..."); | orgmobDatabase.remove( baz ); | orgmobDatabase.flush(); | log.debug( "baz removed."); | findBazs(); // update bazList | } | } | | @Destroy @Remove | public void destroy() { | } | | } | Baz.java | package com.orgmob.play; | | import java.io.Serializable; | | import javax.persistence.Column; | import javax.persistence.Entity; | import javax.persistence.GeneratedValue; | import javax.persistence.Id; | import javax.persistence.Table; | | import org.jboss.seam.annotations.Name; | | @Entity | @Name("baz") | @Table(name="BAZS") | public class Baz implements Serializable { | | private long id; | private String name; | | @Id | @Column(name="BAZ_ID") | @GeneratedValue | public Long getId() { | return id; | } | public void setId(Long id) { | this.id = id; | } | | @Column(name="NAME") | public String getName() { | System.out.println("Baz.getName():returning:"+name); | return name; | } | public void setName(String name) { | System.out.println("Baz.setName():setting name to:"+name); | this.name = name; | } | | @Override | public String toString() { | return "Baz[" + name + "]"; | } | | } | Quux.java | package com.orgmob.play; | | import java.io.Serializable; | | import javax.persistence.Column; | import javax.persistence.Entity; | import javax.persistence.GeneratedValue; | import javax.persistence.Id; | import javax.persistence.Table; | | import org.jboss.seam.annotations.Name; | | @Entity | @Name("quux") | @Table(name="QUUXS") | public class Quux implements Serializable { | | private long id; | private String name; | | @Id | @Column(name="QUUX_ID") | @GeneratedValue | public Long getId() { | return id; | } | public void setId(Long id) { | this.id = id; | } | | @Column(name="NAME") | public String getName() { | System.out.println("Quux.getName():returning:"+name); | return name; | } | public void setName(String name) { | System.out.println("Quux.setName():setting name to:"+name); | this.name = name; | } | | @Override | public String toString() { | return "Quux[" + name + "]"; | } | | } | BQManager.java | package com.orgmob.play; | | import javax.ejb.Local; | | @Local | public interface BQManager { | public void findQuuxen(); | public void findBazs(); | public void stop(); | public void createBaz(); | public void createBazSpecifyingName(); | public void commitQuux(); | public void commitBaz(); | public void deleteBaz(); | public void destroy(); | } | persistence.xml | <persistence> | <persistence-unit name="orgmobDB"> | <provider>org.hibernate.ejb.HibernatePersistence</provider> | <jta-data-source>java:/DefaultDS</jta-data-source> | <properties> | <property name="hibernate.hbm2ddl.auto" value="create-drop"/> | <property name="jboss.entity.manager.factory.jndi.name" | value="java:/EntityManagerFactories/orgmobData" /> | </properties> | </persistence-unit> | </persistence> | components.xml | <components> | <component name="org.jboss.seam.core.init"> | <property name="myFacesLifecycleBug">true</property> | <property name="jndiPattern">member/#{ejbName}/local</property> | </component> | <component class="org.jboss.seam.core.Ejb" | installed="false"/> | <component name="orgmobDatabase" | class="org.jboss.seam.core.ManagedPersistenceContext"> | <property name="persistenceUnitJndiName">java:/EntityManagerFactories/orgmobData</property> | </component> | </components> | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962327#3962327 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962327 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user