You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Glenn, Scott" <Sc...@umusic.com> on 2004/04/30 17:10:10 UTC

RE: Indexed properties working formbean->htmlform, not working ht mlform->formbean

I think the id attribute on the iterate tag must match the getter on the
"get row (index)" method of your form bean. For example I have:-

<logic:iterate id="rows" name="RCF" property="rows" indexId="counter">

and my form bean is:-

	private List rows = null;

	public FormRow getRows (int index)
	{		
		return (RenamePDFFormRow)rows.get(index);
	}

When the form is submitted, the getRows(int) method is called to retrieve
the relevant entry in the collection, which is then reflected to set the
individual properties.

So try adding this to your form:-

	public FundamentalsInfo getIsf (int index)
	{
		return fundInfo.get(index);
	}

Hope that helps, 

Scott.

> -----Original Message-----
> From: Berke, Wayne [IT] [mailto:wayne.berke@citigroup.com]
> Sent: 30 April 2004 15:50
> To: Struts Users Mailing List
> Subject: Indexed properties working formbean->htmlform, not working
> htmlform->formbean
> 
> I've been tearing my hair out trying to get indexed properties
> to work.  Apparently, there is some correspondence between the HTML
> fields and the ActionForm indexed properties because when the ActionForm
> is initialized, it does correctly populate the default HTML form fields.
> However, when I modify an HTML field that corresponds to an indexed
> property and submit the form, that change does not get reflected in
> the ActionForm.
> 
> I tried turning on log4j trace in BeanUtils and PropertyUtils and it seems
> like the correct setProperty calls are being made, but printing out the
> ActionForm fields shows no change from the defaults.
> 
> Any information, including suggestions for how to further debug this
> would be greatly appreciated.
> 
> My JSP looks like this:
> 
> <table width="770" border="0" cellspacing="0" cellpadding="0"
> class="bglt3">
> 	<html:form action="/IS">
> 	<logic:iterate name="isForm" id="isf" property="fundInfo"
> indexId="ix">
> 	<tr>
> 		<td width="45%" valign="middle">NM:</strong>&nbsp;
> 			<html:text name="isf"
> 				property="colName" indexed="true" size="10"
> styleClass="t11" />
> 					&nbsp;&nbsp;
> 		<td width="45%" valign="middle">DISP:</strong>&nbsp;
> 			<html:text name="isf"
> 				property="displayName" indexed="true"
size="10"
> styleClass="t11" />
> 					&nbsp;&nbsp;
> 	</tr>
> 	</logic:iterate>
> 	<tr><td>
> 	<html:submit /></td></td>
> 	</html:form>
> </table>
> 
> The ActionForm is:
> 
> public class ISF extends ActionForm {
> 
> 	private List fundInfo = new ArrayList();
> 	{
> 		System.out.println("INITIALIZING!!!!!!!!!");
> 		fundInfo.add(new FundamentalsInfo("ONE", "1"));
> 		fundInfo.add(new FundamentalsInfo("TWO", "2"));
> 		fundInfo.add(new FundamentalsInfo("THREE", "3"));
> 	}
> 	public List getFundInfo() {
> 		return fundInfo;
> 	}
> 	public void setFundInfo(List fi) {
> 		fundInfo = fi;
> 	}
> 	public FundamentalsInfo getFundInfo(int index) {
> 		return (FundamentalsInfo) fundInfo.get(index);
> 	}
> 	public void setFundInfo(int index, FundamentalsInfo fi) {
> 		fundInfo.set(index, fi);
> 	}
> 
> 	public void reset(ActionMapping mapping, HttpServletRequest request)
> {
> 	}
> }
> 
> A FundamentalsInfo object is just a simple bean with two attributes,
> colName and
> displayName.
> 
> The associated Action simply prints out the contents of the fundInfo list
> and it
> shows that the fields never change from the values they were initialized
> with.
> 
> Wayne
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org