简体   繁体   中英

Using binding attribute causes javax.faces.FacesException: Cannot find component with identifier

I have a problem I can't quite get a handle on.

First the context: I am developing a web application using Primefaces 3.5 (yes, unfortunately I am stuck with this old version for now), running on JBoss 7.

There is a form with id "form" encompassing all following xhtml code.

I have a component in my view which is provided by usage of the binding attribute:

<p:dashboard id="dashboard" binding="#{myBackingBean.dashboard}" />

Then sometimes I would like to perform an ajax update on this component, this is done by using the RemoteCommand component of primefaces:

<p:remoteCommand
actionListener="#{myBackingBean.someActionListener()}"
process="@this" id="myRmtCmd" oncomplete="myJsFunction();"
update=":form:dashboard" name="myRemoteCommand" />

The RemoteCommand is triggered by a clicking on a Link:

<a href="#!" onclick="myRemoteCommand();">Some Text</a>

This works pretty well so far. However after deploying this code to production I sometimes get a FacesException:

javax.faces.FacesException: Cannot find component with identifier ":form:dashboard"
referenced from "form:myRmtCmd".

This is where my problem lies because I cannot reliably reproduce this exception. My question is this: What could lead to this exception being thrown? It seems to work 95 % of the time but being the perfectionist I am (and many of you reading this are as well, I'm sure ;) ) I would like this code to work 100 % of the time. What am I missing?

Before answering please consider these constraints:

  • yes, i have to use the binding attribute for providing the dashboard as I need a great deal of control over what gets added to the component
  • to avoid using IDs I also tried updating the dashboard by its css class via one of primefaces' advanced selectors: @(.ui-dashboard) - this also does not work!
  • yes, it would be possible to use a commandbutton/link instead of wiring up the remotecommand component to a simple html link but in this case the link is rendered by a JSF renderer component and I made some bad experiences with dynamically adding buttons etc (due to JSF Spec Issue 790 )

Cheers, ps

I also had this weird behavior.

There are probably more than one component bindded to #{myBackingBean.dashboard} , so the first one sets the id and there will be no one called " dashboard ".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM