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=3919138#3919138

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


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to