Hello,

unfortunately, selectBooleanCheckbox does not give converters any chance
to be called and assume backing property is of type boolean or
java.lang.Boolean.
>From HtmlCheckboxRendererBase, around line 300:

    public Object getConvertedValue(FacesContext facesContext,
            UIComponent component, Object submittedValue)
            throws ConverterException {
       
org.apache.myfaces.shared_impl.renderkit.RendererUtils.checkParamValidity(facesContext,
component, null);
        if (component instanceof UISelectBoolean) {
            return submittedValue;

while this is, as far as i know, consistent with JSF release
implementation i don't see in specs where it should not call converter.
On the other hand, the Renderer api clearly states that calling
converter is "optional" :(

what about using <h:selectOneRadio>and <f:selectItem> instead?

Regards,
David Delbecq
En l'instant précis du 18/07/07 10:01, David Steinkopff s'exprimait en
ces termes:
> 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


-- 
http://www.noooxml.org/

Reply via email to