You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Sertic Mirko, Bedag" <Mi...@bedag.ch> on 2007/05/03 15:40:54 UTC

Problem with duplicated client-ids

Hi there

I am having problems with the following exception :

Caused by: org.apache.jasper.JasperException: Client-id : _id9 is
duplicated in the faces tree. Component : _idJsp3:_id9, path:
{Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId:
/createevn.jsp][Class: oracle.adf.view.faces.component.html.HtmlHtml,Id:
_idJsp0][Class: oracle.adf.view.faces.component.html.HtmlBody,Id:
_idJsp2][Class: javax.faces.component.html.HtmlForm,Id: _idJsp3][Class:
ch.bedag.common.web.component.cdbund.CDBundPageComponent,Id:
_idJsp4][Class:
ch.bedag.common.web.component.layout.GridbagLayoutComponent,Id:
_idJsp26][Class:
ch.bedag.common.web.component.layout.GridbagLayoutCellComponent,Id:
_idJsp58][Class:
ch.bedag.common.web.component.layout.TitledBoxComponent,Id:
_idJsp59][Class:
ch.bedag.common.web.component.layout.GridbagLayoutComponent,Id:
_idJsp60][Class:
ch.bedag.common.web.component.layout.GridbagLayoutCellComponent,Id:
_idJsp62][Class:
ch.bedag.common.web.component.input.InputfieldComponent,Id:
_idJsp63][Class: javax.faces.component.UICommand,Id: _id9]}

This happens when i navigate to the page, navigate to another page and
finally when i come back to the origin, the above
exception is generated. The question is now : why is there a duplicate
id? I thought that the whole component tree would
be rebuild when a new page is accessed. It is a custom component, but it
worked very well in prior projects. The only
Difference is here that is use a binding for the component to access it
from a backing bean. Am i missing something?

Thanks a lot for your help

Mirko




AW: Problem with duplicated client-ids

Posted by "Sertic Mirko, Bedag" <Mi...@bedag.ch>.
Hi

Thanks for the hint! I am using session scoped backing
beans, and a custom component that does a kind of dynamic
include, so the contents of the page dynamically depending
on ist state. The binding properties were not set to null
for the components, so this is the explaination for the
problem. I set them to null, and everything is fine :-)

Thanks again for your help
Mirko

-----Ursprüngliche Nachricht-----
Von: Simon Kitching [mailto:simon.kitching@rhe.co.nz] 
Gesendet: Freitag, 4. Mai 2007 00:31
An: MyFaces Discussion
Betreff: Re: Problem with duplicated client-ids

Sertic Mirko, Bedag wrote:
> Hi there
> 
> I am having problems with the following exception :
> 
> Caused by:_ org.apache.jasper.JasperException_: Client-id : _id9 is 
> duplicated in the faces tree. Component : _idJsp3:_id9, path: 
> {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: 
> /createevn.jsp][Class: oracle.adf.view.faces.component.html.HtmlHtml,Id: 
> _idJsp0][Class: oracle.adf.view.faces.component.html.HtmlBody,Id: 
> _idJsp2][Class: javax.faces.component.html.HtmlForm,Id: _idJsp3][Class: 
> ch.bedag.common.web.component.cdbund.CDBundPageComponent,Id: 
> _idJsp4][Class: 
> ch.bedag.common.web.component.layout.GridbagLayoutComponent,Id: 
> _idJsp26][Class: 
> ch.bedag.common.web.component.layout.GridbagLayoutCellComponent,Id: 
> _idJsp58][Class: 
> ch.bedag.common.web.component.layout.TitledBoxComponent,Id: 
> _idJsp59][Class: 
> ch.bedag.common.web.component.layout.GridbagLayoutComponent,Id: 
> _idJsp60][Class: 
> ch.bedag.common.web.component.layout.GridbagLayoutCellComponent,Id: 
> _idJsp62][Class: 
> ch.bedag.common.web.component.input.InputfieldComponent,Id: 
> _idJsp63][Class: javax.faces.component.UICommand,Id: _id9]}
> 
> This happens when i navigate to the page, navigate to another page and 
> finally when i come back to the origin, the above
> 
> exception is generated. The question is now : why is there a duplicate 
> id? I thought that the whole component tree would 
> be rebuild when a new page is accessed. It is a custom component, but it 
> worked very well in prior projects. The only
> Difference is here that is use a binding for the component to access it 
> from a backing bean. Am i missing something?

Is your binding stored in a bean that is session-scoped, ie still exists 
when you come to re-render the page?

When using JSF1.1+JSP, the first render goes like this:

For each JSF tag in the page, if the tag has a binding attribute then:
  * Read from the specified property.
  * If that returns non-null then attach the returned component to the 
view tree and at skip any further processing of that JSF tag.

If no binding exists, or binding returns null then create a new 
component instance, set properties from tag. If no explicit id is 
defined on the tag then create a dynamic one.

So yes binding can be related to this "duplicate id" problem. However it 
normally doesn't cause any problem because the id computed the first 
time it was created should be the same as on the next time. Do you 
perhaps have a <c:if> or <c:forEach> tag in the page so that on 
different renders there are different numbers of components actually 
created for the page? That would definitely cause problems when combined 
with bindings...

I would suggest firstly to avoid using c:if or c:forEach if you are 
currently doing so. These tags interact very badly with JSF1.1.

Secondly, having session-scoped beans with bindings that are still valid 
when a page is re-rendered after being somewhere else is not very nice. 
This is very memory-inefficient for a start; because each component has 
references to its parent and children this effectively holds the entire 
component tree for that view in memory for the length of the http 
session. You might want to look into using t:saveState + request-scoped 
backing beans instead.

Regards,

Simon

Re: Problem with duplicated client-ids

Posted by Simon Kitching <si...@rhe.co.nz>.
Sertic Mirko, Bedag wrote:
> Hi there
> 
> I am having problems with the following exception :
> 
> Caused by:_ org.apache.jasper.JasperException_: Client-id : _id9 is 
> duplicated in the faces tree. Component : _idJsp3:_id9, path: 
> {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: 
> /createevn.jsp][Class: oracle.adf.view.faces.component.html.HtmlHtml,Id: 
> _idJsp0][Class: oracle.adf.view.faces.component.html.HtmlBody,Id: 
> _idJsp2][Class: javax.faces.component.html.HtmlForm,Id: _idJsp3][Class: 
> ch.bedag.common.web.component.cdbund.CDBundPageComponent,Id: 
> _idJsp4][Class: 
> ch.bedag.common.web.component.layout.GridbagLayoutComponent,Id: 
> _idJsp26][Class: 
> ch.bedag.common.web.component.layout.GridbagLayoutCellComponent,Id: 
> _idJsp58][Class: 
> ch.bedag.common.web.component.layout.TitledBoxComponent,Id: 
> _idJsp59][Class: 
> ch.bedag.common.web.component.layout.GridbagLayoutComponent,Id: 
> _idJsp60][Class: 
> ch.bedag.common.web.component.layout.GridbagLayoutCellComponent,Id: 
> _idJsp62][Class: 
> ch.bedag.common.web.component.input.InputfieldComponent,Id: 
> _idJsp63][Class: javax.faces.component.UICommand,Id: _id9]}
> 
> This happens when i navigate to the page, navigate to another page and 
> finally when i come back to the origin, the above
> 
> exception is generated. The question is now : why is there a duplicate 
> id? I thought that the whole component tree would 
> be rebuild when a new page is accessed. It is a custom component, but it 
> worked very well in prior projects. The only
> Difference is here that is use a binding for the component to access it 
> from a backing bean. Am i missing something?

Is your binding stored in a bean that is session-scoped, ie still exists 
when you come to re-render the page?

When using JSF1.1+JSP, the first render goes like this:

For each JSF tag in the page, if the tag has a binding attribute then:
  * Read from the specified property.
  * If that returns non-null then attach the returned component to the 
view tree and at skip any further processing of that JSF tag.

If no binding exists, or binding returns null then create a new 
component instance, set properties from tag. If no explicit id is 
defined on the tag then create a dynamic one.

So yes binding can be related to this "duplicate id" problem. However it 
normally doesn't cause any problem because the id computed the first 
time it was created should be the same as on the next time. Do you 
perhaps have a <c:if> or <c:forEach> tag in the page so that on 
different renders there are different numbers of components actually 
created for the page? That would definitely cause problems when combined 
with bindings...

I would suggest firstly to avoid using c:if or c:forEach if you are 
currently doing so. These tags interact very badly with JSF1.1.

Secondly, having session-scoped beans with bindings that are still valid 
when a page is re-rendered after being somewhere else is not very nice. 
This is very memory-inefficient for a start; because each component has 
references to its parent and children this effectively holds the entire 
component tree for that view in memory for the length of the http 
session. You might want to look into using t:saveState + request-scoped 
backing beans instead.

Regards,

Simon