myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Porryman <>
Subject inputSuggest (non AjaX) with objects and converter
Date Tue, 05 Mar 2013 19:27:46 GMT
I'd like to use the tag s:inputSuggest but to retrieve an Object not a
string. If a use a Map<String, String> its renders ok, however mi converter
is never invoke, and if I use a Map<Object, String> I get a
ClassCastException cause can't convert an object to a string. 
my jsp code is as follows :

<s:inputSuggest id="prueba2" required="true" converter="aparatoConverter"
value="#{clienteAparato.selectMapAparatosCA}" />

Converter is:

    public Object getAsObject(FacesContext arg0, UIComponent arg1, String
arg2) throws ConverterException {
        AparatoBO apBO=getAparatoBO();
        Aparato ap=apBO.getAparato(Integer.valueOf(arg2));
        return ap;

    public String getAsString(FacesContext arg0, UIComponent arg1, Object
arg2) throws ConverterException {
        if(arg2!= null){
        Aparato ap=(Aparato) arg2;
        return ap.getId()+"";
        else return "";

    private AparatoBO getAparatoBO(){
        return (AparatoBO) FacesContextUtils.

and bean code is:

    public Map getSelectMapAparatosCA(){
        Map aux=new HashMap();
        Iterator i=this.aparatoBO.getListaAparato().iterator();
            Aparato ap=(Aparato);
        return aux;

Aparato class atributes

public class Aparato implements Serializable{
    private int id;
    private String modelo;
    private long codBarras;
    private double precioVenta;
    private TipoAparato tipoAparato;
    private Marca marca;

Thank you very much in advance

View this message in context:
Sent from the MyFaces - Users mailing list archive at

View raw message