Note that there are some explanatory texts on larger screens.

plurals
  1. POPrimefaces ManyCheckbox inside ui:repeat calls setter method only for last loop
    primarykey
    data
    text
    <p>I have a <code>&lt;p:selectManyCheckbox&gt;</code> inside <code>&lt;ui:repeat&gt;</code>, getting it's items from a List of a certain Object Class (provided by <code>&lt;ui:repeat&gt;</code>-variable) and is supposed to save the chosen items into another List of the same Object Class. But it calls the setter method <code>#{cartBean.setSelectedExtras}</code> only for the last entry (last iteration of <code>&lt;ui:repeat&gt;</code>).</p> <pre><code>&lt;ui:repeat var="item" value="#{category.items}"&gt; &lt;p:selectManyCheckbox id="extraCheckbox" value="#{cartBean.selectedExtras}" layout="pageDirection" converter="omnifaces.SelectItemsConverter"&gt; &lt;f:selectItems value="#{item.items5}" var="extra" itemLabel="#{extra.name}"/&gt; &lt;/p:selectManyCheckbox&gt; &lt;/ui:repeat&gt; </code></pre> <p><strong>Update:</strong> I changed the above construct just the way BalusC proposed.<br> Declaration in backing bean is now:</p> <pre><code>private List&lt;List&lt;Item&gt;&gt; selectedExtras = new ArrayList&lt;List&lt;Item&gt;&gt;(); </code></pre> <p>When I check checkboxes that were created by the first loops of <code>&lt;ui:repeat&gt;</code> and click the <code>&lt;p:commandButton&gt;</code> inside the same <code>&lt;h:form&gt;</code> the setter method of <code>selectedExtras</code> is not called. When I check the checkboxes created in the last loop of <code>&lt;ui:repeat&gt;</code> and click the <code>&lt;p:commandButton&gt;</code> I get an Exception: </p> <pre><code>javax.el.PropertyNotFoundException: /lightbox-item.xhtml @57,165 value="#{cartBean.selectedExtras[iteration.index]}": null </code></pre>
    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.
 

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