I think UISelectBoolean can only use boolean types.  You might have to
do the conversion on your bean.  That is, have boolean getters and
setters that call int getters and setters.


On Tue,  7 Dec 2004 11:54:37 +0100, Francesco Consumi
<[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I'm creating a custom converter in order to use smallint database fields with
> boolean components, such as SelectBooleanCheckBox. I'm doing this because
> Firebird SQL doesn't have a real boolean type.
> 
> I've written a very simple converter:
> 
> package frautils.Converters;
> 
> import javax.faces.context.FacesContext;
> import javax.faces.convert.Converter;
> import javax.faces.component.UIComponent;
> import javax.faces.convert.ConverterException;
> 
> public class intBoolConverter implements Converter {
>   public static final String CONVERTER_ID ="intBoolConverter";
> 
>   public Object getAsObject(FacesContext context, UIComponent component,
>                             String newValue) throws ConverterException {
>       return (newValue.equals("1");
> 
>   }
>   public String getAsString(FacesContext context, UIComponent component,
>                             Object value) throws ConverterException {
>     String s = "0";
>     if (value.toString().equals("true")) { s = "1"; };
>     return s;
>   }
> 
> ...and I've registered this in faces-config.xml:
> 
>   <converter>
>     <converter-id>intBoolConverter</converter-id>
>     <converter-class>frautils.Converters.intBoolConverter</converter-class>
>   </converter>
> 
> ..and I'm using that in this way:
> 
>   <h:selectBooleanCheckbox value="#{lista.FRUITO}">
>      <f:converter converterId="intBoolConverter"/>
>   </h:selectBooleanCheckbox>
> 
> ("FRUITO" is a smallint field )
> the problem is that the converter class is never being called, and the
> application returns this error:
> 
> java.lang.ClassCastException: java.lang.Integer
>     at
> javax.faces.component.UISelectBoolean.isSelected(UISelectBoolean.java:38)
>     at
> net.sourceforge.myfaces.renderkit.html.HtmlCheckboxRendererBase.encodeEnd(HtmlCheckboxRendererBase.java:84)
> ...etc.......
> 
> where am I wrong ?
> 
> thanks,
> 
> --
> Francesco Consumi
> Ufficio Sistemi informativi
> Istituto degli Innocenti
> Piazza SS.Annunziata, 12
> 50122 Firenze
> consumi at istitutodeglinnocenti.it
> Tel. +39 055 2037320
> ICQ# 12516133
> 
> 


-- 
If you don't have a GMail account, I probably have 5 invites.  Just ask!
-Heath Borders-Wing
[EMAIL PROTECTED]

Reply via email to