All,
I create a dynamic form using DynaValidatorForm. The form has a property which
is an array of a QuoteItem bean. I have managed to get the form pre-populated
from the database. After the form is displayed, users can then update the qty
field and then submit the form. The problem I have is that the
DynaValidatorForm does not take the Qty values updated by users. The qty values
are always 0 regardless what value I put in. What am I missing? Tips or hints??
TIA
Andy
$$Form declaration$$
<form-bean name="QuoteItemForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="quote" type="com.leonardo.oms.QuoteItem[]"></form-property>
</form-bean>
$$The rendered Html$$
<form name="QuoteItemForm" method="post" action="/coco/processQuoteItem.do?
display=true">
PartID: <input type="text" name="row[0].partID" value="PA123"
readonly="readonly">
Part Qty: <input type="text" name="row[0].partQty"
value="0"></br>
PartID: <input type="text" name="row[1].partID" value="PA234"
readonly="readonly">
Part Qty: <input type="text" name="row[1].partQty"
value="0"></br>
<input type="submit" value="Create Quote">
</form>
$$The action class that process the form$$
public final class ProcessQuoteItemAction extends Action {
public ActionForward perform( ActionMapping mapping,
ActionForm form,
HttpServletRequest
request,
HttpServletResponse
response) {
//Get the form
DynaValidatorForm df = (DynaValidatorForm) 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("else:" + lineItem[i].getPartQty());
}else{
System.out.println("else:" + lineItem[i].getPartQty());
}
}
session.setAttribute("arrListQuote", arrListQuote);
return (mapping.findForward("success"));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]