myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cagatay Civici" <cagatay.civ...@gmail.com>
Subject Re: EntityConverter
Date Sun, 23 Jul 2006 07:33:55 GMT
Hi,

I'm an hibernate user and cannot think of using hibernate-jsf without an
entity converter. We've also written one for our project.

http://www.jroller.com/page/cenkcivici?entry=binding_made_easy_with_jsf

Also I've written a lookup data resolver to load all the data of the given
class to a component as select items.

As Matze said, a wiki would be great, I'll also add more Rogerio,

Regards,

Cagatay

On 7/23/06, Matthias Wessendorf <matzew@apache.org> wrote:
>
> Since I am not a hibernate user but thinking that can be sorta usful
> for other people,
> may I ask you to add this stuff to our wiki ?
>
> Thanks,
>
> On 7/22/06, Rogerio Pereira <rogerio.araujo@gmail.com> wrote:
> > Hi guys!
> >
> > I created a EntityConverter that get the value entered by user in a
> UIInput
> > component and when the form is submited this value is converted to an
> > persistence layer entity that you can managed in you bean as u wish, can
> > work with persistence layers that provide a generic way to load
> entities, e.
> > g. Hibernate session.get(Class, Serializable).
> >
> > The only thing that u need to do is create a class that implement
> > EntityLoader (that belongs to EntityConverter package). And inside this
> > class u do this:
> >
> >     public Object getEntity(Class type, Serializable id) {
> >
> >         Session session = HibernateUtil.currentSession();
> >
> >         Object object = session.get(type, id);
> >
> >         return object;
> >     }
> >
> > and then add this entry to your web.xml :
> >
> >     <context-param>
> >         <param-name>br.eti.faces.entityLoader</param-name>
> >
> > <param-value>br.gov.go.tj.scu.util.EntityLoader</param-value>
> >     </context-param>
> >
> > using in your page:
> >
> >
> > <h:selectOneMenu value="#{bean.selectedEntity}"
> >  converter="#{entityConverter.entity['package.Entity;id']}">
> >     <s:selectItems value="#{bean.entities}"
> >        var="entity" itemLabel="#{ entities.name}"
> >        itemValue="#{entity}" />
> >  </h:selectOneMenu>
> > note: package.Entity is the full class name of your entity and id is the
> > name of your id property in your entity with their get/set methods
> >
> > reading the submited value in your bean:
> >
> > Entity entity = selectedEntity;
> >
> >
> > Uses a little of reflection but tries to do some caching on reflection
> stuff
> > to enhance performance.
> >
> > --
> > Yours truly (Atenciosamente),
> >
> > Rogério
>
>
> --
> Matthias Wessendorf
>
> further stuff:
> blog: http://jroller.com/page/mwessendorf
> mail: mwessendorf-at-gmail-dot-com
>
Mime
View raw message