0

Whenever I run the following code on Home.xhtml page, I get the following exception. I try to call the contents of panel with id = items but without success. It says that compiler cannot find the component with items identifier.

1)part of Home.xhtml

<h:form>
    <p:commandButton type="submit" value="Speak Out" action="#{statusBean.save}" ajax="true" styleClass="buttonstyle" update="items"/>                          
</h:form>


<p:panel id="items">    
    //content       
</p:panel>

2)Exception

Mar 12, 2013 1:38:04 AM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
SEVERE: Error Rendering View[/Home.xhtml]
javax.faces.FacesException: Cannot find component with identifier "items" in view.
    at org.primefaces.util.ComponentUtils.findClientIds(ComponentUtils.java:249)
    at org.primefaces.renderkit.CoreRenderer.buildAjaxRequest(CoreRenderer.java:222)
    at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeMarkup(CommandButtonRenderer.java:81)
    at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeEnd(CommandButtonRenderer.java:53)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:164)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:300)
    at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:181)
    at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:125)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:389)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

Mar 12, 2013 1:38:04 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/FreeBird_v.6] threw exception [Cannot find component with identifier "items" in view.] with root cause
javax.faces.FacesException: Cannot find component with identifier "items" in view.
    at org.primefaces.util.ComponentUtils.findClientIds(ComponentUtils.java:249)
    at org.primefaces.renderkit.CoreRenderer.buildAjaxRequest(CoreRenderer.java:222)
    at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeMarkup(CommandButtonRenderer.java:81)
    at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeEnd(CommandButtonRenderer.java:53)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:164)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:300)
    at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:181)
    at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:125)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:389)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Tapas Bose
  • 28,796
  • 74
  • 215
  • 331
Wizard Sultan
  • 830
  • 7
  • 22
  • 45
  • 2
    try :items, because it's outside the component tree. – berkay Mar 11 '13 at 20:14
  • @berkay you should post an answer :) – partlov Mar 11 '13 at 20:19
  • @berkay Thanks it is working, but can you explain to me why it is outside the component tree. – Wizard Sultan Mar 11 '13 at 20:20
  • 1
    @AmlanKarmakar more specifically it is outside the form within which the `commandButton` is firing. You might want to wrap your panel with another form. in that case the update would be `:formId:panelId`. If you sent the `prependId` attribute to false then the `panelId` will not be preceded with `formId`. – Tapas Bose Mar 11 '13 at 20:22
  • @AmlanKarmakar see also [UIComponentBase#findComponent()](http://docs.oracle.com/cd/E17802_01/j2ee/javaee/javaserverfaces/2.0/docs/api/javax/faces/component/UIComponentBase.html#findComponent%28java.lang.String%29) – partlov Mar 11 '13 at 20:25
  • @ Tapas Bose, thanks for explanations. @ partlov i guess i need some more reputation:) – berkay Mar 11 '13 at 20:28
  • possible duplicate of [How to reference components in JSF ajax? Cannot find component with identifier "foo" in view](http://stackoverflow.com/questions/8634156/how-to-reference-components-in-jsf-ajax-cannot-find-component-with-identifier) – BalusC Mar 13 '13 at 12:47

1 Answers1

1

Okey, shortly you should try :items, because it's outside the component tree. And for more details of using ajax behavior of primefaces you can check the examples in showcase from here. In addition you can use firebug in this case to observe your components. EDIT: After BalusC's warning, it's correct that your problem lies on not due to the it's not inside the same component tree, because it's not in the same NamingContainer.

Standard components like h: form , f: subview and h: dataTable are naming containers. Most sets of components possess in some naming containers, so in your case it's outside of the tag for that reason :items will be correct way to refer it.

Please refer to these posts help you understand the topic nicely:

Community
  • 1
  • 1
berkay
  • 3,907
  • 4
  • 36
  • 51
  • Uh, it's not outside the component tree. It's inside the same component tree, just not in the same `NamingContainer`. Please explain the cause properly. – BalusC Mar 13 '13 at 12:48