This content has been marked as final.
Show 2 replies
-
1. Re: Outject component instace in java code
vata2999 Jun 8, 2011 8:51 AM (in response to alexeicu)I don't know what your need exactly is but for outjecting a component usually use @Out annotation and
sometimes i use @Unwrap annotation to load a specific entity@Name("service") public class Service { @In EntityManager em; @Unwrap public YourEntity getYourEntity(){ return em.createQuery().getSingleResult(); } }
Use in other Bean
@In("#{service}") YourEntity yourentity
-
2. Re: Outject component instace in java code
robshep Jun 9, 2011 6:12 AM (in response to alexeicu)For the Session scope you can do the following:
String myContextVarName = "myContextVarName"; Object mySessionObject = new Object(); if( Contexts.isSessionContextActive() ) { Contexts.getSessionContext().set(myContextVarName, mySessionObject); } else { // oops no session yet. }