I am using a Datatable in JSF1.2 to populate the data received from Seam component/ using a List. The data is getting fetched when I use the list. But when, I want to make the Datatable editable so that the value I am changing on the JSF page can be sent back to the Seam Component/ Backing Bean the list is not passing value to the Seam component/Backing Bean.
I have tried but I am unable to pass the list to Seam component/Backing Bean again.
Below is the code.
JSF code:
<h:dataTable value="#{mainbean.findCustomerlist}" var="findCustomerList">
<h:column>
<f:facet name="header">
<h:outputText value="Sr No" />
</f:facet>
<h:outputText value="#{findCustomerList.id}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Company Name" />
</f:facet>
<h:inputText value="#{findCustomerList.companyName}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Account Number" />
</f:facet>
<h:inputText value="#{findCustomerList.accountNumber}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Contact Number" />
</f:facet>
<h:inputText value="#{findCustomerList.contactNumber}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Contact Name" />
</f:facet>
<h:inputText value="#{findCustomerList.contactName}" />
</h:column>
<br></br>
</h:dataTable>
<h:commandButton value="Update" type="submit" action="#{mainbean.modifyCustomer(findCustomerlist)}" />
Seam Component/Backing Bean Code:
private List<Customer> findCustomerlist=null;
public List<Customer> getFindCustomerlist() {
return findCustomerlist;
}
public void setFindCustomerlist(List<Customer> findCustomerlist) {
this.findCustomerlist = findCustomerlist;
}
public void searchCustomer(ActionEvent actionEvent)
{
findCustomerlist=session.findCustomer(customerName);
}
/* The searchCustomer function works fine and it returns the list to the JSF. But when I use the modifyCustomer function to retrieve the value from JSF then it is not working.*/
public void modifyCustomer(List<Customer> findCustomerlist)
{
session.updateCustomer(findCustomerlist);
System.out.println("Inside modifyCustomer");
System.out.println(findCustomerlist.get(0).getCompanyName());
}