[jboss-user] [JBoss Seam] - Re: One Seam component calling another

2008-01-02 Thread breako
Thanks for the replies, you spotted my mistake.
Happy New Year!

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

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


[jboss-user] [JBoss Seam] - Re: One Seam component calling another

2007-12-31 Thread sdegardin
"gsegura" wrote : Hi, 
  | it could be just the different variable name:
  | 
  | private EntityManager em;
  | and
  | private EntityManager entityManager;
  | 
  | regards

and if you don't want to use component name has field name, specify the 
component name in the "value" parameter of the In annotation

@In(value="em") private EntityManager entityManager;

Cheers,

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

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


[jboss-user] [JBoss Seam] - Re: One Seam component calling another

2007-12-31 Thread gsegura
Hi, 
it could be just the different variable name:

private EntityManager em;
and
private EntityManager entityManager;

regards

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

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


[jboss-user] [JBoss Seam] - Re: One Seam component calling another

2007-12-31 Thread breako
"sdegardin" wrote : 
  | 1: use @In annotation. (recommended)  
  | 
Thanks for your suggestion. I used the @In annotation but the problem is that 
the second Seam component does not get it's Seam managed EntityManager set up 
correctly.

Basically, I have two Seam components both involved in the same transacation. 
Both Seam Components have Seam managed EntityManagers and because there are 
involved in the same transaction, the persistence context should be propagated 
and shared. 

First Seam Component:


  | @Name("manager")
  | @Scope(CONVERSATION)
  | public class ManagerPojo {
  | 
  |   @In
  |   private EntityManager em;
  | 
  |   @In (required=false, value="instancegenerator", create=true)  
  |   private InstanceGeneratorPOJO instanceGeneratorPOJO;
  | 
  |   @Begin(join=true, flushMode=FlushModeType.MANUAL)
  |   public void persist() {
  | //...
  | instanceGeneratorPOJO.getNextInstance("Person");
  | //...
  |   }
  | 
  |   //...
  | }
  | 

Second Seam Component:

  | @Name("instancegenerator")
  | @Scope(CONVERSATION)
  | public class InstanceGeneratorPOJO { 
  |  @In 
  |  private EntityManager entityManager;  
  |   
  |  public Long getNextInstance(String type) {
  |  //... 
  |  }
  | 
  | }
  | 

When persist() is invoked I get:


  | 15:50:41,937 FATAL [application] org.jboss.seam.RequiredException: @In 
attribute requires non-null value: instancegenerator.entityManager
  | javax.faces.el.EvaluationException: org.jboss.seam.RequiredException: @In 
attribute requires non-null value: instancegenerator.entityManager
  | 

Note: If I remove the create=true in the first Seam component, i.e.


  |   @In (required=false, value="instancegenerator")  
  |   private InstanceGeneratorPOJO instanceGeneratorPOJO;
  | 

the instanceGenerator reference is null and I get a Null pointer exception in 
the persist() method

anybody got any ideas?



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

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


[jboss-user] [JBoss Seam] - Re: One Seam component calling another

2007-12-31 Thread sdegardin
Hello,


As far I know, there are 2 ways :

1: use @In annotation. (recommended)  

2: use Component.getInstance() (from non-seam component)

Have a look for options in booth technique.

Correct if I'm wrong.
Cheers,

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

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