@Scope(ScopeType.SESSION)
  | @Name("whateverConverter")
  | @Interceptors(SeamInterceptor.class)
  | 
  | public class WhateverConveter implements Converter, Serializable {
  | 
  |     @In(create=true)
  |     private EntityManager em;   //Hint: There needs to be an "em" in your 
components.xml, see 9.4.2 of the Seam reference
  | 
  |     public String getAsString(....Object object) {
  | 
  |         return ( (Whatever) object ).getId().toString();
  | 
  |     }
  | 
  |     public Object getAsObject(....String string) {
  | 
  |         return em.find(Whatever.class, Long.valueOf(string));
  | 
  |     }
  | 
  | 
  | }

This converter example would make it possible to use your Entity beans in 
select menus. As I said I even added caching (even with a possibility to mark 
the contained entities as dirty if changes happen) and a method to generate 
SelectItems (with the same cache). But that's just an idea of the nice things 
you can do with a converter.

PS: I reconstructed my converter and the caching went from an inner class 
directly into my code. And now it works like a charm. Inner classes seam to 
make problems in Converters, keep that in mind if you ever want to do that.

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

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

Reply via email to