Return-Path: X-Original-To: apmail-myfaces-users-archive@www.apache.org Delivered-To: apmail-myfaces-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C3BF3E85C for ; Sun, 17 Feb 2013 22:13:59 +0000 (UTC) Received: (qmail 60705 invoked by uid 500); 17 Feb 2013 22:13:59 -0000 Delivered-To: apmail-myfaces-users-archive@myfaces.apache.org Received: (qmail 60643 invoked by uid 500); 17 Feb 2013 22:13:59 -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 60633 invoked by uid 99); 17 Feb 2013 22:13:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Feb 2013 22:13:59 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of nithril@gmail.com designates 209.85.128.171 as permitted sender) Received: from [209.85.128.171] (HELO mail-ve0-f171.google.com) (209.85.128.171) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Feb 2013 22:13:52 +0000 Received: by mail-ve0-f171.google.com with SMTP id b10so4334852vea.16 for ; Sun, 17 Feb 2013 14:13:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=re1He5Ec3+jYKAZGUlZKs2KHQ4i9vLqy/giLRmWg+3U=; b=mFfnG3FPvoF4p9k3A/6GvXZCiOj6ploIdgsUc5Z71KRig2jtVpHaMwdHrVl9jPh1vD 2YVyZYjDchMbOvtxp+8ozoTY/VltrJzyOH1fp7iA2g0rCDcnP6kPpjaCyVtEofu/3Jvj UKNgZ+73+o2yl65GSSvL4A7cwPf8ySI3xD5VIZnqiadBexEAGEkFpHfN+eymXKE9A4xL qan54ly2xVNDJXynhWbVdg4cGFnLaLYfzo1nA2xePPnh6fWO0dh2lJiwO6lx8GOf70Sv 8bBHVUtjz/JiSa2VaWZ3AefzRnJkgQap+LyF7Ih/2HxzsXlkkiW1bQUSw+NmOEn0Owt7 ANcA== MIME-Version: 1.0 X-Received: by 10.52.90.18 with SMTP id bs18mr11012324vdb.89.1361139211553; Sun, 17 Feb 2013 14:13:31 -0800 (PST) Received: by 10.220.18.130 with HTTP; Sun, 17 Feb 2013 14:13:31 -0800 (PST) In-Reply-To: References: Date: Sun, 17 Feb 2013 23:13:31 +0100 Message-ID: Subject: Re: Duplicate id on stylesheet inserted with ResourceDependency From: Nicolas Labrot To: MyFaces Discussion Content-Type: multipart/alternative; boundary=20cf307f325231cb3904d5f2ebd1 X-Virus-Checked: Checked by ClamAV on apache.org --20cf307f325231cb3904d5f2ebd1 Content-Type: text/plain; charset=ISO-8859-1 Thanks for your answer Leonardo. It's a bit annoying to not be able to use c:forEach on a dynamic purpose. Hope it will be fixe on 2.2. Nicolas On Sun, Feb 17, 2013 at 12:36 AM, Leonardo Uribe wrote: > Hi > > The problem is caused by use c:forEach tag, iterating over something > that is not "application scoped". > > The reason why c:forEach should be avoided in cases like the one > shown here is Partial State Saving (PSS) algorithm works under the > assumption that the same view can be generated between requests, > so when the delta is applied, it can be applied over the same > components. > > The issue has been widely studied and the conclusion has been that > c:forEach cannot really be fixed because c:forEach does not have an > underlying UIComponent instance that encapsultate what's inside > and in that way generate unique stable ids. > > Create a custom component that works in MyFaces and Mojarra is not > really possible, because the component requires to know some > implementation details. > > Is there any solution? maybe something like this (I don't know if the EL > is correct, but I hope you get the idea): > > > > > > > > > And repeat the same code as many times as options you can put > on sessionBean.values. In that way, PSS algorithm will reserve the > necessary slots. > > In theory, a variant of c:forEach can be created to fix this problem, but > it requires to store sessionBean.values into delta view state, to ensure > stability of PSS algorithm. The previous example works because the > values of src="#{...}" are stored into the state and unique ids are > generated per each slot (by c:if effect). > > Note any variant of c:forEach will add a strong dependency of the code > with MyFaces, so that's the reason why it hasn't been done before. > > Other alternative to make it work is disable PSS, or use > org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE > web config param, but that is one step back, because without PSS the > state in session will not be optimally used. > > regards, > > Leonardo Uribe > > 2013/2/16 Nicolas Labrot : > > Hello, > > > > I'm glad to post my first message on this ml ;) > > > > I have the infamous but well known duplicate id behaviour with the > > following code: > > > > > update=":myForm"/> > > > update=":myForm"/> > > > > > > > > > > > > > > > > > > At the beginning "sessionBean.values" is empty. > > Action 1 : User clicks on "add", the add action adds "form0.xhtml" to > > "sessionBean.values". > > Action 2 : User clicks on "add", the add action adds "form1.xhtml" to > > "sessionBean.values". > > > > *form0.xhtml contains : * > > > > fileUploadListener="#{sessionBean.handleFileUpload}"/> > > * > > * > > *form1.xhtml contains :* > > > > > > My issue is action 2 returns a duplicate id exception: > > > > java.lang.IllegalStateException > > > > > > > > > > j_id4 is the stylesheet of the fileUpload component : > > @ResourceDependency(library="primefaces", > name="fileupload/fileupload.css"), > > > > This stylesheet is inserted with action 1. And it seems myfaces tries to > > insert it with action 2 too. > > > > Do I do something wrong ? > > > > Thanks for your help! > > > > Nicolas > --20cf307f325231cb3904d5f2ebd1--