Form and table are on the same page. When user adds form details and clicks add, the data should be copied to the table.
When user enters the details and clicks add for the second time(already existing data in table) the first value is overwritten by the new value and the next in list is empty.
How can we display both values on the table.
Name.xhtml
<h:form>
<h:inputText value="#{bean.fName}"/>
<h:inputText value="#{bean.lName}"/>
<h:dataTable value="#{bean.list}" var="name">
<h:column>
<h:outputText value="#{name.fName}">
</h:column>
</h:dataTable>
<h:commandLink action="#{bean.add}"/>
</h:form>
Bean.java //Bean class is ViewScoped
@ManagedProperty(value="#{buyerTO}") protected BuyerTo buyerTO;
List buyerTOList = new ArrayList(); // BuyerTO is in ViewScope
public String addBuyer(){
buyerTOList.add(buyerTO);
buyerTO = new BuyerTO();
return "";
}