I have a Composite Component that uses ajax to change multiple elements when an item is selected. I am also using Primefaces p:ajax and p:commandButton instead of f:ajax if that makes any difference.
The problem is I cannot find the right update attribute to use on the components so that the whole component updates. For example, in the following button:
<p:commandButton id="slGoUSA"
value="USA"
rendered="#{cc.USAButtonOn}"
actionListener="#{cc.doSetUSA}"
update="???" />
I have tried all the following and none of them work:
update="@this"
update="@form"
update="#{cc.clientId}"
update=":#{cc.clientId}"
update="#{cc.clientId}:localID"
update=":#{cc.clientId}:localID"
The only thing that does work is this:
update="#{cc.attrs.update}"
and then the client page passes some clientId that includes the composite component. However I don't want to force the user to include an update parameter in the component invocation. Is there a convenient way of doing this?
Update
Ok I think it might help if I showed a complete test case. I implement a UINamingContainer to back the composite component like this:
/*
* Test code
*/
package com.myapp.app.component;
import java.io.Serializable;
import javax.faces.component.FacesComponent;
import javax.faces.component.UINamingContainer;
@FacesComponent(value="qctest")
public class Qctest extends UINamingContainer implements Serializable {
private enum StateKey { Counter }
public Qctest() { }
@Override
public String getFamily() { return "javax.faces.NamingContainer"; }
public Integer getCounter() {
Integer i = (Integer) getStateHelper().get(StateKey.Counter);
if (i == null) i = Integer.valueOf(1);
else i += 1;
getStateHelper().put(StateKey.Counter, i);
return i;
}
}
Then the cc definition looks like this:
<!-- INTERFACE -->
<cc:interface componentType="qctest">
</cc:interface>
<!-- IMPLEMENTATION -->
<cc:implementation>
<h:outputText id="outText" value="Counter is now: #{cc.counter}" />
<br/>
<p:commandButton value="Hit Me" update=":#{cc.clientId}" />
<br/>
<h:commandButton value="Or Hit Me" >
<f:ajax render=":#{cc.clientId}"/>
</h:commandButton>
</cc:implementation>
</html>
This code is basically the OMG my first AJAX page ever! application, except it is inside a composite component instead of a regular page with normal backing bean.
Neither button succeeds in doing the update. Firebug shows the XHR being sent, but the response does not update the counter. None of the different values for update or render works. In the case shown, the primefaces button seems to do nothing, in the case of the JSF command button I get a dialog box that says:
malformedXML: During update: test2form:xyz not found
This seems to me to be the most trivial use of AJAX inside a Composite Component. Can anyone explain what could be going on?