Return-Path: Delivered-To: apmail-myfaces-users-archive@www.apache.org Received: (qmail 59094 invoked from network); 23 Jan 2008 06:35:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Jan 2008 06:35:01 -0000 Received: (qmail 68251 invoked by uid 500); 23 Jan 2008 06:34:48 -0000 Delivered-To: apmail-myfaces-users-archive@myfaces.apache.org Received: (qmail 68218 invoked by uid 500); 23 Jan 2008 06:34:48 -0000 Mailing-List: contact users-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Discussion" Delivered-To: mailing list users@myfaces.apache.org Received: (qmail 68207 invoked by uid 99); 23 Jan 2008 06:34:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Jan 2008 22:34:48 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mwessendorf@gmail.com designates 209.85.146.181 as permitted sender) Received: from [209.85.146.181] (HELO wa-out-1112.google.com) (209.85.146.181) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jan 2008 06:34:20 +0000 Received: by wa-out-1112.google.com with SMTP id l24so5126313waf.22 for ; Tue, 22 Jan 2008 22:34:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=JFwGllkCf7e6oNzBQX3eIfXQbOuQ6c8aMVrw0bYGH6Q=; b=PSRdAcU/HnvsWGwG0zcm34cmKQAC09CVlUE4jRvMF/7WX8n3AI4C+IPLh0oa8sI6BzgDBsAzEmZX9dLU3i8FH7hVBoV9W1MIVeQPmNBmOK/3SU3CIKaB55yrTDMYajLuX7pVHKWytJC9/aOctcaOsHMhuqNE0FVr3yFskasMP7s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=SewE0XIuolIgImwzgtqjeuv+V5zaUA7ayJlSfxUgcLddaKfeUV6cJTcC0z4ueW1z6+TaTIfDsxjDgJHTyNrKCKjWXor4YAn1gcxJX45VRkJhwlPflK5EXFVNj8hpRbmlJKgYGOTLjha5TBx7E9Zdc4Y4LFHlrcyRvWNVOzYmESQ= Received: by 10.115.107.1 with SMTP id j1mr6893494wam.55.1201070066674; Tue, 22 Jan 2008 22:34:26 -0800 (PST) Received: by 10.115.54.11 with HTTP; Tue, 22 Jan 2008 22:34:26 -0800 (PST) Message-ID: <71235db40801222234p1001b9e7lcb4fa26bad391180@mail.gmail.com> Date: Tue, 22 Jan 2008 22:34:26 -0800 From: "Matthias Wessendorf" Sender: mwessendorf@gmail.com To: "MyFaces Discussion" Subject: Re: Registering a Converter for a "primitive Object" In-Reply-To: <47963513.9010504@oma.be> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <47961D81.1060608@gmail.com> <47963513.9010504@oma.be> X-Google-Sender-Auth: 4942c452ebe0d747 X-Virus-Checked: Checked by ClamAV on apache.org Trinidad is overriding the "primitive" converters as well. here is what our built-in faces-cfg does for Double: javax.faces.Double org.apache.myfaces.trinidadinternal.convert.DoubleCo= nverter and java.lang.Double org.apache.myfaces.trinidadinternal.convert.DoubleCo= nverter -M On Jan 22, 2008 10:25 AM, david delbecq wrote: > As per specifications: > > 3.3.3 Standard Converter Implementations > > JSF provides a set of standard Converter implementations. A JSF > implementation must > register the DateTime and Number converters by name with the > Application instance > for this web application, as described in the table below. This > ensures that the converters are > available for subsequent calls to Application.createConverter(). > Each concrete > implementation class must define a static final String constant > CONVERTER_ID whose value > is the standard converter id under which this Converter is registered= . > The following converter id values must be registered to create > instances of the specified > Converter implementation classes: > ..... > javax.faces.Double -- An instance of > javax.faces.convert.DoubleConverter (or a subclass of this class). > > > > I recommend you change your converter declaration to match the > specification rules. Note: i am not 100% sure it is overridable from > default behaviour, but this part of section is hopefull: > > A JSF implementation must register converters for all of the > following classes using the by- > type registration mechanism: > ... > java.lang.Double, and java.lang.Double.TYPE -- An instance of > javax.faces.convert.DoubleConverter (or a subclass of this class). > > > > Alan Romaniuc a =E9crit : > > > > > > > Hi, > > > > I can not set a converter for the type java.lang.Double. I would like > > to do that once the we use comma to separate decimals (Using a locale > > based converter) > > I am using myfaces 1.2.1-snapshot from 17 december, but I tried with > > others too. > > I use something like that: > > > > iDoubleConverter > > java.lang.Double > > > > jsf.converter.InternationalDoubleConverter > > > > > > > > > > And my converter: > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D > > public Object getAsObject(FacesContext facesContext, UIComponent > > uiComponent, String value) { > > FacesContext fc =3D FacesContext.getCurrentInstance(); > > Locale l =3D fc.getViewRoot().getLocale(); > > if (value !=3D null) { > > value =3D value.trim(); > > if (value.length() > 0) { > > try { > > return > > NumberFormat.getNumberInstance(l).parse(value).doubleValue(); > > } catch (ParseException ex) { > > throw new ConverterException("Bad String " + value > > + " " + l); > > } catch (NumberFormatException e) { > > throw new ConverterException("Format is not a > > Number for locale" + l); > > } > > } > > } > > return null; > > } > > > > public String getAsString(FacesContext facesContext, UIComponent > > uiComponent, Object value) { > > > > if (value =3D=3D null) { > > return ""; > > } > > if (value instanceof String) { > > return (String) value; > > } > > try { > > FacesContext fc =3D FacesContext.getCurrentInstance(); > > Locale l =3D fc.getViewRoot().getLocale(); > > log.debug("Converting Object" + value + " to " + > > l.toString()); > > return NumberFormat.getNumberInstance(l).format(value); > > } catch (Exception e) { > > throw new ConverterException("Format is not a Number"); > > } > > } > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > If I use a converter in the component, it will work, showing that the > > converter is working, but I woul like to register it to all Double > > objects. > > > > Is this a bug from myfaces? > > > > > > > > > > > > > > > > --=20 Matthias Wessendorf further stuff: blog: http://matthiaswessendorf.wordpress.com/ sessions: http://www.slideshare.net/mwessendorf mail: matzew-at-apache-dot-org