No Problem,

Personally, I'm don't usually use named entities. They seem a little pointless 
since they just get created and popped into the context variables without 
initialization.  For example, the user entity that gets pushed into the 
authenticator bean in some examples. It is only useful once the authenticator 
has authenticated the login, loaded the user and outjected an instance of the 
user.  I can't see much use for named entities over the factory methods except 
possibly in the user case where you might want a blank instance available to 
avoid any null exceptions, and you can't use a factory since the user may not 
have logged in yet.

In your case, you may want to look at the @Factory annotation instead. You can 
annotate access methods for the entities in your backing beans with any name 
you like, it will outject the entities as a named context variable. If you do 
this, you won't need to reference the entities as MyBacking.getEntity1

i.e.


  | 
  | class MyBackingBean
  | 
  |   private Entity entity1;
  |   private Entity entity2;
  | 
  |   @Factory('entity1')
  |   public getEntity1() {
  |      return entity1;
  |   }
  | 
  |   @Factory('entity2')
  |   public getEntity2() {
  |      return entity2;
  |   }
  | 
  | }
  | 

Now, in your jsf page, you can reference #{entity1} and #{entity2}

It all depends on how you initialize your entities, whether you pass entities 
around or rely on parameters (the method I prefer).

You have to bear in mind that factory methods get called whenever you reference 
#{entity1} (or 2), so if you have any weird pre-initialization that happens to 
load the entities, you have to make sure that has run before you access the 
factory. For this reason, I prefer to use parameters since it is less coupled. 

Lastly, having the bean in conversation scope shouldn't be a problem, what's 
the problem with it?

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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4106963
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to