Return-Path: Delivered-To: apmail-myfaces-dev-archive@www.apache.org Received: (qmail 78111 invoked from network); 9 Aug 2005 11:27:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Aug 2005 11:27:15 -0000 Received: (qmail 56250 invoked by uid 500); 9 Aug 2005 11:27:15 -0000 Delivered-To: apmail-myfaces-dev-archive@myfaces.apache.org Received: (qmail 55985 invoked by uid 500); 9 Aug 2005 11:27:14 -0000 Mailing-List: contact dev-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list dev@myfaces.apache.org Received: (qmail 55972 invoked by uid 99); 9 Aug 2005 11:27:14 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Aug 2005 04:27:14 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of manfred.geiler@gmail.com designates 64.233.184.204 as permitted sender) Received: from [64.233.184.204] (HELO wproxy.gmail.com) (64.233.184.204) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Aug 2005 04:27:36 -0700 Received: by wproxy.gmail.com with SMTP id 67so805433wri for ; Tue, 09 Aug 2005 04:27:12 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=WLeTRw/jBIFc13UOFHjJFIUMFmt5QE2UAqQJKSqHyyAHeDL0GCxmWVKfA1SQyRalYnsFE8NMh7bJOJQ2CvBfRQPgA8MlIxvkSkGzYgsgaVehNE7ZwgUUuI+JaaZqyu6V2KRADvxmn7X2iYXezjYdA6a3T5Kd9jBbvnxhRZQPeU8= Received: by 10.54.56.24 with SMTP id e24mr2627040wra; Tue, 09 Aug 2005 04:27:12 -0700 (PDT) Received: by 10.54.89.10 with HTTP; Tue, 9 Aug 2005 04:27:12 -0700 (PDT) Message-ID: <564d4f6805080904271626f842@mail.gmail.com> Date: Tue, 9 Aug 2005 13:27:12 +0200 From: Manfred Geiler To: MyFaces Development Subject: Re: svn commit: r225327 - /myfaces/api/trunk/src/java/javax/faces/component/UIComponentBase.java In-Reply-To: <1123099438.21440.73.camel@sv> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20050726152530.68378.qmail@minotaur.apache.org> <564d4f6805072712481055035c@mail.gmail.com> <1123099438.21440.73.camel@sv> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Just had a look at the spec (i.e. javadoc) and the RI source code: How we handled the List was absolutely correct IMO. The problem you have, would also arise with the RI. So, I do not so a reason to do this "trick" in the MyFaces implementation. The drawback of your patch is: If someone has a List other than an ArrayList the method will fail. -Manfred 2005/8/3, Sylvain Vieujot : > Hello Manfred, > =20 > Here is a specific example where savestate would fail : > > =20 > The save state would return a List, and not a LinkedList. > So if you use somewhere in your code myLinkedList.pool(), it would fail. > In fact it fails earlier, as the saved value can't be coerced to a > LinkedList. > =20 > I think this is important as you expect the saveState to return exactly > what you saved, and not a object with a different type. > =20 > In my applications, I have a base backing bean that uses this scheme : > =20 > public class BaseFace implements Serializable { > =20 > public LinkedList getStates(){ > return new LinkedList(); > } > =20 > /** > * Restore the states. > */ > public void setStates(@SuppressWarnings("unused") > LinkedList states) throws Exception{ > // NoOp > } > ... > } > =20 > It's quite nice because at you can extend this class easily and still ha= ve > an easy job saving / restoring the state : > =20 > public class BaseFaceForObjectWithUnid extends > BaseFace { > ... > =20 > @Override > public LinkedList getStates(){ > LinkedList states =3D super.getStates(); > states.add( object =3D=3D null ? null : object.getUnid() ); > return states; > } > =20 > @Override > public void setStates(LinkedList states) throws Exception{ > super.setStates(states); > setUnid(states =3D=3D null ? null : (String)states.poll()); > } > ... > } > =20 > It worked fine until the related UIComponentBase had been modified. > So I limited the case for ArrayList. > =20 > But I still have problems with this > UIComponentBase.saveAttachedState code, as I guess similar > problems with other types (like a custom class implementing List) could > arrise. > What I understand is that we need this "trick" to check if the List does= n't > contain any StateHolder. > If I'm right and if we still need that, then maybe we can do a recursive > check for any StateHolder object, and if there is none, then just seriali= ze > the object. > =20 > By the way, it's not exactly clear for me why we need to have a special > treatment for StateHolders. > Could you clarify this for me please ? > =20 > Thanks, > =20 > Sylvain. >=20 > =20 > =20 > On Wed, 2005-07-27 at 21:48 +0200, Manfred Geiler wrote:=20 > Sylvain, > This change does not make much sense IMHO. > Why do you check for ArrayList instead of List. There is only a List > cast after that, so why not just check for List? > Is there anything a LinkedList does not correctly implement from the > List interface?! >=20 > -Manfred >=20 > 2005/7/26, svieujot@apache.org : > > Author: svieujot > > Date: Tue Jul 26 08:25:26 2005 > > New Revision: 225327 > >=20 > > URL: http://svn.apache.org/viewcvs?rev=3D225327&view=3Drev > > Log: > > Bugfix for savestate with a linkedlist (couldn't coerce a value of type > "java.util.ArrayList" to type "java.util.LinkedList". > >=20 > > Modified: > > > myfaces/api/trunk/src/java/javax/faces/component/UIComponentBase.java > >=20 > > Modified: > myfaces/api/trunk/src/java/javax/faces/component/UIComponentBase.java > > URL: > http://svn.apache.org/viewcvs/myfaces/api/trunk/src/java/javax/faces/comp= onent/UIComponentBase.java?rev=3D225327&r1=3D225326&r2=3D225327&view=3Ddiff > > > =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=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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > > --- > myfaces/api/trunk/src/java/javax/faces/component/UIComponentBase.java > (original) > > +++ > myfaces/api/trunk/src/java/javax/faces/component/UIComponentBase.java > Tue Jul 26 08:25:26 2005 > > @@ -593,9 +593,9 @@ > > Object attachedObject) > > { > > if (attachedObject =3D=3D null) return null; > > - if (attachedObject instanceof List) > > + if (attachedObject instanceof ArrayList) > > { > > - ArrayList lst =3D new > ArrayList(((List)attachedObject).size()); > > + List lst =3D new > ArrayList(((List)attachedObject).size()); > > for (Iterator it =3D ((List)attachedObject).iterator(); > it.hasNext(); ) > > { > > lst.add(saveAttachedState(context, it.next())); > >=20 > >=20 > > >=20 >