Hi,
I have an array of QuoteItem object stored in a DynaActionForm. The QuoteItem is a bean with the following setter and getter for these properties: partID, partDesc, partUOM
and partQty.
This is a definition of the DynaActionForm
<form-bean name="QuoteItemForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="quote" type="com.leonardo.oms.QuoteItem[]"></form-property>
</form-bean>
The rendered html looks like this:
<form name="QuoteItemForm" method="post" action="/coco/processQuoteItem.do?display=true">
PartID: PA123
:
art 123
:
C</br>
Part Qty: <input type="text" name="lineItem[0].partQty" value=""></br>
PartID: PA234
:
art 234
:
C</br>
Part Qty: <input type="text" name="lineItem[1].partQty" value=""></br>
PartID: PA456
:
art 456
:
C</br>
Part Qty: <input type="text" name="lineItem[2].partQty" value=""></br>
<input type="submit" value="Create Quote">
</form>
I entered the qty values and submit the form, the ProcessQuoteItem.action that processes the form is:
public ActionForward perform( ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
//Get the form
DynaActionForm df = (DynaActionForm) form;
ArrayList arrListQuote = new ArrayList();
//Create session object
HttpSession session = request.getSession();
//get the QuoteItem array
QuoteItem[] lineItem = (QuoteItem[]) df.get("quote");
for(int i=0; i<lineItem.length; i++ ){
if(lineItem[i].getPartQty() != null){
arrListQuote.add(lineItem[i]);
System.out.println(lineItem[i].getPartQty());
}else{
System.out.println(lineItem[i].getPartQty());
}
}
session.setAttribute("arrListQuote", arrListQuote);
return (mapping.findForward("success"));
}
The problem is lineItem[i].getpartQty() does not retain the qty values that are submitted with the form. The system.out shows blanks. Where do I go wrong? Any tips or hints...
TIA
-Vili