[jboss-user] [JBoss Seam] - Factory and injection in EntityHome

lightbulb432 do-not-reply at jboss.com
Sun Feb 18 04:39:08 EST 2007

I have an EntityHome that contains the following code. When I go to page to create the entity, the myEntity factory variable is already populated with the first entity in the dataModel list, even though nothing has been selected (and myEntityHome.managed evaluates to true, even though it shouldn't, because nothing from the list has been selected). Why might this be?

  | public class MyEntityHome extends EntityHome<MyEntity> {
  |     @Factory
  |     public MyEntity getMyEntity() { return getInstance(); }
  |     @In("#{myQuery.dataModel.rowData}")
  |     public void setInstance(MyEntity instance) {
  | 	    super.setInstance(instance);
  |     }
  | }

In the create page, I have the following. The first time I access the page, myEntity.name is populated with the value of the first row of "myQuery.dataModel", even though "myQuery.dataModel.rowData" should be empty because no row has yet been selected. How do I fix this so that it behaves correctly and shows nothing, because nothing has been selected? This should work, right?

  |     <h:inputText value="#{myEntity.name}" />
  |     <h:commandButton value="Create" action="#{myEntityHome.persist}" />
  | </h:form>

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

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

More information about the jboss-user mailing list