[jboss-user] [JBoss Seam] - Re: How do I reload a Data Model on a SessionBean everytime

Andy Gibson do-not-reply at jboss.com
Fri Dec 14 10:10:09 EST 2007


Also, I think there is another small problem with the code you have there. I could be wrong on this, so hopefully someone will correct me if that is the case.

You have outjection on the datamodel for users, and also return a value for the factory method. 

When you return the value from the factory, that is outjected as the variable "users". When the method completes, the Seam interceptor then looks for outjected variables and outjects the data model as "users". At that point, you have set it twice. While I don't think it would be a problem at run time, the return value from the factory method is unnecessary, and it should be like : 


  | @Name("userList")
  | @Scope(PAGE)
  | @Restrict("#{identity.loggedIn}")
  | public class UserList implements UserListInterface {
  | 
  | 	@DataModel("users")
  | 	private List<User> users;
  | 
  | 	@Factory("users")
  | 	public void getUsers() { 
  |              users = entityManager.createQuery(....).getResultList();
  |         } 
  | 
  | }
  | 
  | 

Here, you are using the factory to assign the value, and the @Datamodel annotation handles the outjection.

For more details see : 

http://docs.jboss.com/seam/latest/reference/en/html/concepts.html#d0e3302

Cheers,

Andy


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

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



More information about the jboss-user mailing list