Karen
Karen

Reputation: 1

All panels disappear when deleting the last panel with PrimeFaces 5.3

Please see the image below.

image

Those images show how things work with my current code. When I delete the last panel and push the update button, all the panels disappear somehow. It works well when I do the same with the rest of the panels.

If anyone knows how to solve this problems, it would be a great help. Thanks in advance.

I've attatched the code below (just in case):

【xhtml】

<html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:p="http://primefaces.org/ui"
        xmlns:ui="http://java.sun.com/jsf/facelets">
      <h:head></h:head>
      <h:body>
        <h:form>
          <ui:repeat value="#{newapp001.list}" var="item" >
            <p:panel header="#{item}" closable="true" >
              <p>my information</p>
            </p:panel>
          </ui:repeat>
          <p:commandButton value="Update" update="@form" />
        </h:form>
      </h:body>
    </html>

【ManagedBean】 package sample;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

@Named("newapp001")
@SessionScoped
public class NewApp001 implements Serializable
{
    private static final long serialVersionUID = 2610647621325923945L;

    private List<String> list;

    public NewApp001()
    {
        this.list = new ArrayList<>();
        this.list.add("aaa");
        this.list.add("bbb");
        this.list.add("ccc");
        this.list.add("ddd");

        return;
    }

    public List<String> getList()
    {
        return this.list;
    }
}   

Upvotes: 0

Views: 228

Answers (1)

Vsevolod Golovanov
Vsevolod Golovanov

Reputation: 4206

When you press the button, the panels' visibility state gets submitted. It's definitely a PF bug, that the last rendered panel's state affects all panels.

Since you don't seem to be interested in tracking the visibility state, the easiest fix would be to not process the panels, thus not storing the visibility state on the server:

<p:commandButton value="Update" process="@this" update="@form" />

Upvotes: 0

Related Questions