I am new to struts, and working on a form where a user would use checkboxes
to select specific records from a list .The list object is of type
'purchaseOrder' and it can contain 1 or more products. My question is how
would the struts action class know which of the product has been clicked.

following is the JSP code:

///////////////////////////////////////////////////////////////
<nested:root name="invoicePOForm">
Invoice Details for Purchase Order Number: <nested:write
property="purchaseOrderNumber"/>
<nested:iterate property="purchaseOrderProduct">
<tr>
<td Width="15%"><nested:write property="productId"/> </td>
<td Width="25%"><nested:write property="productTitle"/></td>
<td Width="10%"><nested:write property="orderedQty"/> </td>
<td Width="10%"><nested:write property="receivedQty"/> </td>
<td Width="10%"><nested:write property="invoicedQty"/> </td>
<td Width="15%"><nested:write property="costPrice"/> </td>
<td Width="15%"><nested:text property="invoiceUnitPrice"/> </td>
<td Width="15%"><nested:text property="invoiceTotalPrice"/> </td>
<td Width="10%"><nested:text property="invoiceQty"/> </td>
<td Width="15%"><html:checkbox property="selectedCheckbox" value="ok"/>
</td>

</nested:iterate>
</nested:root>
</table>
<html:submit> Submit </html:submit>

/////////////////////////

Follwowing is the form bean:
public PurchaseOrderProduct m_aPurchaseOrderProduct;
public String m_sPurchaseOrderNumber;
public String selectedCheckbox[]=new String[]{};

public String[] getSelectedCheckbox() {
return selectedCheckbox;
}


public void setSelectedCheckbox(String[] selectedCheckbox) {
this.selectedCheckbox = selectedCheckbox;
}



public String getPurchaseOrderNumber() {
return m_sPurchaseOrderNumber;
}

public void setPurchaseOrderNumber(String m_sPurchaseOrderNumber) {
this.m_sPurchaseOrderNumber = m_sPurchaseOrderNumber;}


public PurchaseOrder getPurchaseOrderProduct() {
return m_aPurchaseOrder;
}

public void setPurchaseOrderProduct(PurchaseOrder m_aInvoicePurchaseOrder) {
this.m_aPurchaseOrder = m_aInvoicePurchaseOrder;
}

public List<PurchaseOrderProduct> getPurchaseOrderProduct() {
return m_aPurchaseOrderProduct;
}

public void setPurchaseOrderProduct(List<PurchaseOrderProduct>
m_aPurchaseOrderProduct) {
this.m_aPurchaseOrderProduct = m_aPurchaseOrderProduct;
}


public void clearAll(){
this.m_aPurchaseOrder=null;
}


public void reset(ActionMapping mapping, HttpServletRequest request){
this.selectedCheckbox=new String[]{};
}


}

///////////////////////////////////////////////////

Following is part of Action class:

List<PurchaseOrder>
poList=Service.getInvoicePurchaseOrder(request.getParameter("cid"));
PurchaseOrder ipo=poList.get(0);
actionForm.clearAll();
actionForm.setPurchaseOrderNumber(ipo.getPurchaseOrderNumber());
actionForm.setPurchaseOrderProduct(poList.get(0).getProducts());

//////////////////////////////////////////////////////
-- 
View this message in context: 
http://www.nabble.com/Struts-form-checkbox-tf4341628.html#a12367571
Sent from the Struts - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to