File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes DynaActionForm does not retain the values submitted Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "DynaActionForm does not retain the values submitted " Watch "DynaActionForm does not retain the values submitted " New topic

DynaActionForm does not retain the values submitted

Vili Leonardo

Joined: Mar 12, 2004
Posts: 18

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>

The rendered html looks like this:

<form name="QuoteItemForm" method="post" action="/coco/">

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">

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){

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...

Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

I don't think I've ever seen an ActionForward coded out before, so I'll assume you know what you're doing with that one.

I do recommend using:

HttpSession session = request.getSession(false);

as this will prevent many possible debug frustrations.

A good workman is known by his tools.
Vili Leonardo

Joined: Mar 12, 2004
Posts: 18

Basically, I want to build a dynamically sized form. I follow an approach outlined in this article.

Is this the right way of creating dynamic sized form?

I agree. Here's the link:
subject: DynaActionForm does not retain the values submitted