Hello, 

Got same problem, tried same approach, 
but I still get a null instance of EntityManager after adding getInstance to 
the getAsObject method in the custom converter: 

Component.getInstance("em", true);

Questions:
1. Is it that I need to declare the Seam Managed bean "em"  somewhere else for 
this to be referenced ?
2. Do I need to declare this class as SLSB to be able to use the EntityManager 
instance?


This is the custom converter class : (same as original posting)


  | ....
  | @Name("MyCustomConverter")
  | @Scope(ScopeType.EVENT)
  | @Intercept(InterceptionType.ALWAYS)
  | public class MyCustomConverted implements Converter
  |     @In(create=true)
  |     EntityManager em;
  |     ....
  |     

Could you please provide any directions, hints or ideas ?

Thanks !


"js8523" wrote : Hi 
  | 
  | Worked like a treat. 
  | 
  | 
  |   | /**
  |   |          * Fetches the contract object direct from the database each 
time it is selected 
  |   |          */
  |   |         public Object getAsObject (FacesContext context, UIComponent 
component, String value){
  |   |                 log.debug("getAsObject: Called with value = " + value);
  |   |                 
  |   |                 // Fetch the entity manager from the one managed in 
seam. 
  |   |                 EntityManager em = 
(EntityManager)Component.getInstance("em", true);
  |   |                 return (Object)(Contract)em.find(Contract.class, 
Long.valueOf(value).longValue());
  |   |         }
  |   | 
  | 
  | Thanks for the help. 
  | 
  | Thinking about the reverse engineering tool, it would be possible to 
automatically generate the different converters as long as each entity had a 
@Id and a field that could be used as the name element (the tricky part). 
  | 
  | As far as extending seam with further annotations, I will have to think 
about this further (i.e. how the converter could be generalised further, to 
lookup any type of entity, rather than converter per entity type). Allow 
possibly the converters could be created and cached at seam scanner time for 
each entity component that had @Selectable annotation?, this scanner task would 
also need to dynamically register the converters with jsf/myfaces which I 
believe is possible using the myfaces Application class (don't know about the 
RI implementation).  
  | 
  | The entity class annotated with @Selectable would have to have an @Id 
attribute and a attribute annotated with something like @SelectionName for the 
displayed name of the object in the selectItems.  I don't know if it possible 
to pass in the function that you want to use dynamically to a function, but if 
it is then its a possibility? 
  | 
  | Just thoughts currently. 
  | 
  | James 


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

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

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to