ui:repeat p:fields collapsed not working

UI Components for JSF
Post Reply
grburgos
Posts: 180
Joined: 30 Sep 2010, 00:45

22 Jul 2016, 05:07

Hello to all!

I need to display categories dynamically using the combination of ui:repeat and selectManyCheckbox. At this moment the code snippet below renders the categories properly and when the user selects the categories it sets the values correctly.

The issue I'm seeing is when I set the code that allows the user to manually collapse a p:fieldset. Let say there are 3 categories (A,B,C), if the user selects and collapses category C. The only backing bean that gets called is category C and the flag that I use does get set. The problem that I see is that ALL categories end up being collapsed when the ajax call updates the screen. If the user collapses/opens any other category all categories end up being affected. I have tried to debug this behavior and I see that the banking bean always gets the right value but the component behaves incorrectly. I tested this with Mojarra and Myfaces 2.2.10 both showed the same behavior.

Code: Select all

<ui:repeat value="#{controller.categories}" var="category">
                 <p:fieldset legend="#{category.name]}" toggleable="true" toggleSpeed="500" collapsed="#{category.collapsed}" >
                  <p:ajax event="toggle" listener="#{category.handleToggle}" process="@this" update="@form"/>
                  <p:selectManyCheckbox rendered="#{category.type==1}" layout="responsive" columns="3" value="#{category.selected}" converter="categoryConverter">
                    <f:selectItems value="#{category.value}" var="keyword" itemLabel="#{keyword.code}" itemValue="#{keyword}" />
                  </p:selectManyCheckbox>

                  </p:fieldset>
 </ui:repeat>
Thank you for your words of wisdom.
Netbeans 14, Apache Tomcat 9, JDK 11, PrimeFaces 11

grburgos
Posts: 180
Joined: 30 Sep 2010, 00:45

19 Jan 2017, 18:31

It seems the javascript generated for the tags are not linked correctly. It seems the same event call is tagged to all newly generated component.
Netbeans 14, Apache Tomcat 9, JDK 11, PrimeFaces 11

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

19 Jan 2017, 22:44

why do you update the whole form then?

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

20 Jan 2017, 02:54

Agreed don't update @form. Be more selective with what you update. Also try p:repeat instead of ui:repeat. The reason is PrimeFaces p:repeat does some special things for generating ID's correctly.

http://www.primefaces.org/showcase/ui/data/repeat.xhtml
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 36 guests