0
votes

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;
    }
}   
1
When you click on the command button, you update "@form". This means calling all the getters of your bean. you didn't call process of the ajax request to call the setters before performing the updateShady Hussein
Thank you for your comment. As you can see in the answer, updating "@form" wasn't really a problem. After putting the " process="@this" " it worked as I've expected.Karen

1 Answers

0
votes

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" />