myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Steinkopff" <david.steinko...@googlemail.com>
Subject custom converter and BooleanCheckbox doens´t work together
Date Wed, 18 Jul 2007 08:01:36 GMT
Hello,

I try to set up a custom converter for a BooleanCheckbox, because I
need custom boolean values in my bean.

public class BooleanConverter implements Converter {

    public BooleanConverter() {}

    public Object getAsObject(FacesContext facesContext, UIComponent
uIComponent, String string) throws ConverterException {
        if(Boolean.parseBoolean(string)) {
            return "Y";
        }
        return "N";
    }

    public String getAsString(FacesContext facesContext, UIComponent
uIComponent, Object object) throws ConverterException {
        if("Y".equals(object)) {
            return Boolean.toString(true);
        }
        if("N".equals(object))
            return Boolean.toString(false);
        throw new ConverterException();
    }

}

I make an entry in my faces-config and add it with <f:converter
converterId="myconverter"/>

If I modify my checkbox and make a request, getAsObject will never
called. If I reload the page with the checkbox will getAsString called
with the String "0" or "1".

Give it any possiblity to say JSF save me "Y" for true and "N" for false.

regards
David

Mime
View raw message