Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I find update/render parameter inside a composite component?
    text
    copied!<p>I have a Composite Component that uses ajax to change multiple elements when an item is selected. I am also using Primefaces <strong>p:ajax</strong> and <strong>p:commandButton</strong> instead of <strong>f:ajax</strong> if that makes any difference.</p> <p>The problem is I cannot find the right <strong>update</strong> attribute to use on the components so that the whole component updates. For example, in the following button:</p> <pre><code>&lt;p:commandButton id="slGoUSA" value="USA" rendered="#{cc.USAButtonOn}" actionListener="#{cc.doSetUSA}" update="???" /&gt; </code></pre> <p>I have tried all the following and none of them work:</p> <pre><code>update="@this" update="@form" update="#{cc.clientId}" update=":#{cc.clientId}" update="#{cc.clientId}:localID" update=":#{cc.clientId}:localID" </code></pre> <p>The only thing that <em>does</em> work is this:</p> <pre><code>update="#{cc.attrs.update}" </code></pre> <p>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?</p> <hr/> <h1>Update</h1> <p>Ok I think it might help if I showed a complete test case. I implement a UINamingContainer to back the composite component like this:</p> <pre><code>/* * 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; } } </code></pre> <p>Then the cc definition looks like this: </p> <pre><code>&lt;!-- INTERFACE --&gt; &lt;cc:interface componentType="qctest"&gt; &lt;/cc:interface&gt; &lt;!-- IMPLEMENTATION --&gt; &lt;cc:implementation&gt; &lt;h:outputText id="outText" value="Counter is now: #{cc.counter}" /&gt; &lt;br/&gt; &lt;p:commandButton value="Hit Me" update=":#{cc.clientId}" /&gt; &lt;br/&gt; &lt;h:commandButton value="Or Hit Me" &gt; &lt;f:ajax render=":#{cc.clientId}"/&gt; &lt;/h:commandButton&gt; &lt;/cc:implementation&gt; &lt;/html&gt; </code></pre> <p>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.</p> <p>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 <strong>update</strong> or <strong>render</strong> 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:</p> <pre><code>malformedXML: During update: test2form:xyz not found </code></pre> <p>This seems to me to be the most trivial use of AJAX inside a Composite Component. Can anyone explain what could be going on?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload