Hi i am very new to primefaces. I Tried the following functionality.
I add a button to primefaces datatable as a column.
Based on the button I add new row to same data table.
For this i use the following code.
in vendorcontacts.xhtml
<p:dataTable id="dt" var="pmr" value="#{globalMaster.vendorContactsList}"
style="width:900px;">
<p:column headerText="Organisation">
<h:outputText value="#{pmr.contactSno}" />
</p:column>
<p:column headerText="Program">
<h:outputText value="#{pmr.location}" />
</p:column>
<p:column headerText="Action" >
<p:commandButton value="Add New" action="#{globalMaster.getVendorContactsList}" />
</p:column>
</p:dataTable>
And my Bean code is:
public List<VendorContactDetails> getVendorContactsList(){
try{
VendorContactDetails veneContactDetails=new VendorContactDetails();
vendorConList.add(veneContactDetails);
}catch(Exception e){
e.printStackTrace();
}return vendorConList;
}
And now the problem is;
Intially my view page displays single row.
When i click the add new button my view page displays 3 rows instead of second row.
I find something in debug mode my list method calls no.of times(i.e no.of properties in my modal class i.e VendorContactDetails)
I change my bean scope session to view scope .but no use.
Is there any mistake in my code.Please guide me