selectOneMenuにリストされているAlbumエンティティのコンバーターがありますが、selectManyMenuで使用するには、どのような変更が必要ですか?
selectManyMenuで使用するコンバーターの実例を高く評価します。
SelectOneMenuのコンバーター
package converter;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
import javax.persistence.EntityManager;
import entities.Album;
import util.EntityUtil;
@FacesConverter("albumconverter")
public class AlbumConverter implements Converter {
EntityManager em = EntityUtil.getEntityManager();
public Object getAsObject(FacesContext context, UIComponent component, String value) {
if (value == null || value.length() == 0) {
return null;
}
Album album = em.find(
Album.class,
Long.parseLong(value));
return album;
}
public String getAsString(FacesContext context, UIComponent component, Object value) {
return value instanceof Album ?
((Album) value).getAlbumId().toString() : "";
}
}