Hello-
I've searched high & low and did my homework to no avail on this problem...
I have a Struts web app that includes a wizard input (multiple JSP pages and
form-properties to one form-bean). Page 2 (JSP) of the wizard includes a table where
the user will input information to be stored into an ArrayList, and subsequently be
stored to an Oracle database via Hibernate.
When the page comes up for editing, an "Add" button appears. When you click the
button, it opens a new table row for editing. You enter information; so far, so good.
Now, when you click add again to open another row, the second row opens, but the
first row of information you typed in disappears!
Furthermore, when testing values from the action code, it appears that my ArrayList
assignment isn't getting the information from the JSP (or DynaArrayValidation) form.
What could be wrong? Below are my code examples:
=== Excerpt from JSP page === <h5>Matching Funds:</H5><BR> <logic:notEmpty
name="annualRptForm" property="matchingFundLines"><TABLE border=0 cellspacing=1
cellpadding=0> <TR> <TD width='6' align=center
valign=center><B>Del?</B></TD> <TD width='8' align=center
valign=center><B>Federal or Private</B></TD> <TD width='35' align=center
valign=center><B>Funding Entity Name</B></TD> <TD width='15' align=center
valign=center><B>Current Fiscal Year</B></TD> <TD width='15' align=center
valign=center><B>Cash</B></TD> <TD width='15' align=center valign=center><B>In
Kind</B></TD> <TD width='15' align=center valign=center><B>Total</B></TD>
</TR> <logic:iterate id="mfLine" name="annualRptForm" property="matchingFundLines">
<TR> <TD><html:checkbox name="mfLine" indexed="true"
property="deleteMatchingFund" /></TD> <TD><html:text name="mfLine"
indexed="true" property="federal" maxlength="1" size="3" /></TD> <TD><html:text
name="mfLine" indexed="true" property="fundingEntity" maxlength="50" size="35" /></TD>
<TD><html:text name="mfLine" indexed="true" property="fundingYear"
maxlength="4" size="4" /></TD> <TD><html:text name="mfLine" indexed="true"
property="cash" maxlength="8" size="8" /></TD> <TD><html:text name="mfLine"
indexed="true" property="inKind" maxlength="8" size="8" /></TD> <TD><html:text
name="mfLine" indexed="true" property="totalAmountMatchingFunds" maxlength="8"
size="8" /></TD> </TR> </logic:iterate></TABLE></logic:notEmpty><html:image
page="/images/public/addbtn.gif" property="addMatchingFund" value="addMatchingFund"
onclick="bCancel=true;" /><BR><BR> === Excerpt from AnnualRptAction class ===
if (request.getParameter("addMatchingFund.x") != null) {
ArrayList matchingFund = (ArrayList)frm.get("matchingFundLines"); //Statement gets
reached, but assignement doesn't happen. //
System.out.println("size: " + matchingFund.size()); //
System.out.println("matchingFund=" + matchingFund); if (
matchingFund.size() > 0) { // do some validations*
} frm.set("matchingFundLines",matchingFund); // tried
setting ArrayList back to the form, but it is null when this statement is reached.
saveToken(request); return (new
ActionForward(mapping.getInput())); <struts-config> <form-beans>
<form-bean name="annualRptForm" dynamic="true"
type="us.ut.state.dced.coep.forms.DynaValidatorCancelForm"> ...
<form-property name="matchingFundLines" type="java.util.ArrayList" />
... </form-bean> </form-beans>*
=== DynaValidatorCancelForm / DynaActionValidator === package
us.ut.state.dced.coep.forms; import org.apache.struts.action.ActionMapping;import
org.apache.struts.action.*; public class DynaValidatorCancelForm extends
org.apache.struts.validator.DynaValidatorForm { /** Creates a new instance of
DynaValidatorCancelForm */ public DynaValidatorCancelForm() { } public
ActionErrors validate(ActionMapping mapping, javax.servlet.http.HttpServletRequest
request) { if (request.getParameter("delete.x") != null ||
request.getParameter("cancel.x") != null ) { return new ActionErrors();
} return super.validate(mapping, request); } } Thanks very much for
your help! Scott Ottesen