Note that there are some explanatory texts on larger screens.

plurals
  1. POJSF and p:ajax inside p:dataTable inside ui:repeat
    primarykey
    data
    text
    <p>I'm familiar with RichFaces, but relatively new to Primefaces and trying to implement a simple <code>h:graphicImage</code> inside a <code>p:dataTable</code> (additionally inside a <code>ui:repeat</code>). This is the subsequent question of <a href="https://stackoverflow.com/questions/7307407">p:ajax inside h:graphicImage</a>. </p> <p>I will split the following <code>xhtml</code>-code to directly comment the behavior:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.prime.com.tr/ui" xml:lang="en" lang="en"&gt; &lt;h:head id="head"&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;title&gt;Test&lt;/title&gt; &lt;/h:head&gt; &lt;h:body id="body"&gt; &lt;f:view contentType="text/html"&gt; </code></pre> <p>Now the first <code>h:form</code> follows which contains a <code>h:outputText</code> and a <code>h:graphicImage</code>. By clicking on the image the bean method is called and the <em>counter</em> is correctly updated.</p> <pre><code>&lt;h:form id="f1"&gt; &lt;h:outputText id="counter" value="#{clientBean.counter}" /&gt; &lt;h:graphicImage url="/images/circle-ok.png"&gt; &lt;p:ajax event="click" update="counter" process="@this" listener="#{clientBean.tag}"/&gt; &lt;/h:graphicImage&gt; &lt;/h:form&gt;&lt;hr/&gt; </code></pre> <p>In the second <code>h:form</code> the button is inside a <code>p:dataTable</code>. If I click on the image, the bean method is called the counter is updated. (<strong>Note</strong> At firt I've tried to <code>update="counter"</code> without success)</p> <pre><code>&lt;h:form id="f2"&gt; &lt;p:dataTable var="var" value="#{clientBean.vf}"&gt; &lt;p:column&gt; &lt;f:facet name="header"&gt;Tag&lt;/f:facet&gt; &lt;h:graphicImage url="/images/circle-ok.png"&gt; &lt;p:ajax event="click" update="f1:counter" process="@this" listener="#{clientBean.tag}" /&gt; &lt;/h:graphicImage&gt; &lt;/p:column&gt; &lt;/p:dataTable&gt; &lt;/h:form&gt;&lt;hr/&gt; </code></pre> <p>The image inside <code>ui:repeated</code> updates the <em>counter</em> as expected:</p> <pre><code>&lt;ui:repeat var="var1" value="#{clientBean.list}"&gt; &lt;h:form id="f3"&gt; &lt;h:graphicImage url="/images/circle-ok.png"&gt; &lt;p:ajax event="click" update="f1:counter" process="@this" listener="#{clientBean.tag}" /&gt; &lt;/h:graphicImage&gt; </code></pre> <p>Now lets come to the <code>p:dataTable</code> inside a <code>ui:repeat</code>. With this piece of code the bean method is <strong>not</strong> called:</p> <pre><code> &lt;p:dataTable var="var2" value="#{var1.list}"&gt; &lt;p:column&gt; &lt;f:facet name="header"&gt;Tag&lt;/f:facet&gt; &lt;h:graphicImage url="/images/circle-ok.png"&gt; &lt;p:ajax event="click" update="f1:counter" process="@this" listener="#{clientBean.tag}" /&gt; &lt;/h:graphicImage&gt; &lt;/p:column&gt; &lt;/p:dataTable&gt; &lt;/h:form&gt; &lt;/ui:repeat&gt; &lt;/f:view&gt;&lt;/h:body&gt;&lt;/html&gt; </code></pre> <p>In this case I get the <code>&lt;partial-response&gt;&lt;changes&gt;&lt;update id="f1:counter"&gt;...</code>, but the bean method is not called (an inside it's <code>tag()</code>method the <em>counter</em> not updated). This is tested with a debug. I've read <a href="https://stackoverflow.com/questions/6856367/unable-to-use-pajax-on-my-primefaces-datatable">unable to use &lt;p:ajax&gt; on my primeface&#39;s datatable</a> but I have the same behaivour with <code>primefaces-3.0.M3.jar</code> and <code>primefaces-2.2.1.jar</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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