Showing posts from October, 2008

Seam s:convertEntity + glassfish + toplink

.... doesn't go very well together, since Seam wants to access your entityManager, and would want it to be a Hibernate instance...

This is a simple workaround, by replacing s:convertEntity with a custom tag that gives the same result. By remembering the entities displayed to the s:selectItems, using the value of entity.toString() (which is className + hashCode() (which should be unique).).

You might want to tune it maybe not to use hashcode (in case of non uniqueness), and maybe access your entitymanager (toplink) - instead of storing entities in memory.. But in any case this is a good starting point:

package com.petersalomonsen.jsf.persistence.EntityConverter
import java.util.HashMap;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

public class EntityConverter implements Converter {
static HashMap<String,Object> entitiesToRemember = new HashMap<String,Object>();

public Object getAsObject(FacesConte…