Primefaces 3.2RC1 - Cannot find component with identifier

UI Components for JSF
Post Reply
leojribeiro
Posts: 9
Joined: 14 Dec 2011, 13:02

07 Mar 2012, 22:09

Hi everyone,

I have a page running with primefaces 3.0.1 and its working ok, but now i'm trying to use primefaces 3.2RC1 and i'm receiving the following error

Code: Select all

07/03/2012 16:54:24 com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
GRAVE: Error Rendering View[/pages/mainipad.xhtml]
javax.faces.FacesException: Cannot find component with identifier ":frmPage:acCliente" in view.
	at org.primefaces.util.ComponentUtils.findClientIds(ComponentUtils.java:249)
	at org.primefaces.component.behavior.ajax.AjaxBehaviorRenderer.getScript(AjaxBehaviorRenderer.java:72)
	at javax.faces.component.behavior.ClientBehaviorBase.getScript(ClientBehaviorBase.java:103)
	at org.primefaces.renderkit.CoreRenderer.encodeClientBehaviors(CoreRenderer.java:332)
	at org.primefaces.component.selectoneradio.SelectOneRadioRenderer.encodeScript(SelectOneRadioRenderer.java:94)
	at org.primefaces.component.selectoneradio.SelectOneRadioRenderer.encodeEnd(SelectOneRadioRenderer.java:49)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
	at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)

Here's a snippet of the code of the page

Code: Select all

		<h:panelGrid columns="2" id="pg">
		 	<h:outputText value="Contato de" style="font-size:14px;color:#0627D2"/>  
	        <p:selectOneRadio id="tipoContato" value="#{contatoService.tipo}">  
	            <f:selectItem itemLabel="Cliente" itemValue="CLIENTE" />  
	            <f:selectItem itemLabel="Particular" itemValue="PARTICULAR" />  
	            <f:selectItem itemLabel="Empresa" itemValue="EMPRESA" />
	            <p:ajax event="change" process="@this" update=":frmPage:acCliente" listener="#{contatoService.testeAjax}"/>
	        </p:selectOneRadio> 
			<h:outputLabel for="acCliente" value="Cliente" style="font-size:14px;color:#0627D2"/>
		 	<p:autoComplete value="#{contatoService.crmCliente}" id="acCliente" completeMethod="#{contatoService.executeFilterCliente}" maxlength="50" size="50"  
                        	var="cliente" itemLabel="#{cliente.nome}" itemValue="#{cliente}" converter="#{exciaEntityConverter}" forceSelection="true"/>  
I already tried the following in the "update" of the p:selectOneRadio

Code: Select all

update = ":frmPage:pForm:pFromAddUpdt:pg:acCliente"
but i get the error too

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

07 Mar 2012, 23:47

then try other combinations.... one should be the correct one... (and search the forum for similar topics... has been reported several times, and one has gotten a nice detailed response)

cwstanton
Posts: 30
Joined: 28 Feb 2012, 18:36
Location: Colorado Springs, CO, USA

08 Mar 2012, 00:27

It has been my experience, through limited trial and error, that to address an element by ID, you must observe the following rules:

1. If you are addressing it from another element inside the same form, you can just use its ID, as in:

update="acCliente"

2. If you are addressing it from an element in a different form, you must use the :formId:elementId pattern, as in:

update=":pForm:acCliente"


That has worked for me so far...
Charles W. Stanton
(PrimeFaces 3.5, Mojarra 2.1.7, JBoss 7.1.1)

cwstanton
Posts: 30
Joined: 28 Feb 2012, 18:36
Location: Colorado Springs, CO, USA

08 Mar 2012, 01:57

To be absolutely precise, you must provide the chain of NamingContainer objects down to the element you are trying to address.

In basic JSF, this pretty much means Form or DataTable. PrimeFaces has many NamingContainer objects, like:

AccordianPanel, Carousel, DataGrid, DataList, DataTable, Galleria, Sheet, TabView, Tree, TreeTable, etc.

So, if your hierarchy is something like form -> accordianPanel -> someElement, then your update should be:

:formId:accordianPanelId:someElementId

You don't need EVERY element from the top down; just the NamingContainer elements.
Charles W. Stanton
(PrimeFaces 3.5, Mojarra 2.1.7, JBoss 7.1.1)

User avatar
kwintesencja
Posts: 316
Joined: 08 Feb 2010, 20:33
Location: Brazil

08 Mar 2012, 04:36

also remember that composite components are naming containers
Att,

--

Rafael Mauricio Pestano


Primefaces 5.x + JavaEE7(Glassfish 4.x and Wildfly 8)
Conventions Framework
Blog
@realpestano

ardy
Posts: 2
Joined: 08 Mar 2012, 07:06

08 Mar 2012, 09:26

you can use update = "acCliente" , then primefaces will find your component from viewroot .

Hamsterbau
Posts: 409
Joined: 28 Dec 2011, 17:44

08 Mar 2012, 12:49

you can use update = "acCliente" , then primefaces will find your component from viewroot .
Thats not true for all cases. Like mentioned above, relative IDs are only found for the same NamingContainer. If ID comes from another NamingContainer, you have to add the absolute path (with ":" seperator) for update statements - like already pointed out by cwstanton :)
Primefaces 8.0.7 (PF Extensions 8.0)
JSF: Mojarra 2.3.2 (Spec 2.3) - running on WildFly 22

leojribeiro
Posts: 9
Joined: 14 Dec 2011, 13:02

08 Mar 2012, 14:28

Hi everyone,

The problem is fixed. I used the Firebug to inspect the component id and i saw

Code: Select all

pnPrincipal:frmPage:acCliente
So, in the update tag i put

Code: Select all

update=":pnPrincipal:frmPage:acCliente"
And the problem is gone.
The "pnPrincipal" is part of the template page (facelet)

Thanks a lot

ps: my apologies, but my english is not so good

ardy
Posts: 2
Joined: 08 Mar 2012, 07:06

09 Mar 2012, 18:26

Hamsterbau wrote:
you can use update = "acCliente" , then primefaces will find your component from viewroot .
Thats not true for all cases. Like mentioned above, relative IDs are only found for the same NamingContainer. If ID comes from another NamingContainer, you have to add the absolute path (with ":" seperator) for update statements - like already pointed out by cwstanton :)
You are right. My co-worker added findComponentFromView() in org.primefaces.util.ComponentUtils when you can't find component in current NamingContainer , what I thought primefaces team do this.

It's my fault. :oops:

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 59 guests