Note that there are some explanatory texts on larger screens.

plurals
  1. POUse ArrayList , it store current data , but previous data is remove from arrayList
    primarykey
    data
    text
    <p>I use a arrayList. I want data store in it from Entity class.But it store current data and previous data remove from it. My JSF page Code:</p> <pre><code> &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core"&gt; &lt;h:head&gt; &lt;title&gt;Facelet Title&lt;/title&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;h:form&gt; &lt;h:outputText value="ID"/&gt;&lt;br/&gt; &lt;h:inputText value="#{dataTestBeans.data.id}"/&gt;&lt;br/&gt; &lt;h:outputText value="Name"/&gt;&lt;br/&gt; &lt;h:inputText value="#{dataTestBeans.data.name}"/&gt;&lt;br/&gt; &lt;h:outputText value="Address"/&gt;&lt;br/&gt; &lt;h:inputText value="#{dataTestBeans.data.address}"/&gt;&lt;br/&gt; &lt;h:outputText value="Birth Day"/&gt;&lt;br/&gt; &lt;h:inputText value="#{dataTestBeans.data.birthDay}"/&gt;&lt;br/&gt; &lt;h:commandButton action="#{dataTestBeans.abc}" value="Submit" /&gt; &lt;/h:form&gt; &lt;h:form&gt; &lt;c:forEach items="#{dataTestBeans.testArray}" var="dataTest"&gt; &lt;h:outputText value="#{dataTest.id}"/&gt;&lt;br/&gt; &lt;h:outputText value="#{dataTest.name}"/&gt;&lt;br/&gt; &lt;h:outputText value="#{dataTest.address}"/&gt;&lt;br/&gt; &lt;h:outputText value="#{dataTest.birthDay}"/&gt;&lt;br/&gt; &lt;/c:forEach&gt; &lt;/h:form&gt; &lt;/h:body&gt; &lt;/html&gt; </code></pre> <p>My Entity Class code:</p> <pre><code>@ManagedBean(name = "person") @SessionScoped public class Person{ private String id; private String name; private String address; private String birthDay; public Person() { } //getter and setter all veriable } </code></pre> <p>My controller Beans code: </p> <pre><code>@ManagedBean(name="dataTestBeans") @SessionScoped public class DataTestBeans { private Person dataArray; private List&lt;Person&gt; person = new ArrayList&lt;Person&gt;(); public DataTestBeans() { } public Person getData() { if (dataArray == null) { dataArray = new Person(); } return dataArray; } public void abc() { person.add(dataArray); } public List&lt;Person&gt; getTestArray() { return person; } public void setTestArray(List&lt;Person&gt; person) { this.person = person; } } </code></pre> <p>When I run it show the current data</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