0
我正在使用JSF1.2中的數據表來填充從Seam組件/使用列表接收的數據。當我使用列表時,數據正在被抓取。但是,當我希望使Datatable可編輯,以便在JSF頁面上更改的值可以發送回Seam組件/備份Bean時,該列表不會將值傳遞給Seam組件/備份Bean。如何從JSF發送列表到支持Bean
我已經嘗試過了,但是我無法將列表再次傳遞給Seam組件/ Backing Bean。
以下是代碼。
JSF代碼:
<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)}" />
縫組件/輔助Bean代碼:
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());
}