struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Leggett <minf...@sharp.fm>
Subject Re: Html tags and "indexed" property - how does it work?
Date Sat, 27 Sep 2003 23:35:28 GMT
Ted Husted wrote:

> This is really a USER list question, but you may be looking for the 
> indexed properties how-to:
> 
> http://jakarta.apache.org/struts/faqs/indexedprops.html

I have gone through this howto, but its description of what to do is 
very vague. Here is what I have tried so far:

I have a DynaActionForm with properties defined like so:

       <form-property
         name="policycoverLess"
         type="java.lang.String[]" />
       <form-property
         name="policycoverSumInsureds"
         type="java.lang.String[]" />

I populate the above inside my action, and display it successfully 
something like so:

<logic:iterate id="policycoverName" indexId="index" name="form" 
property="policycoverNames">
   <html:text indexed="true" property="<%=\"policycoverSumInsureds[\" + 
index + \"]\"%>" size="15" />
   <html:submit indexed="true" property="policycoverLess" value="-" />
</logic:iterate>

The above html renders an input text tag, and a submit tag, with correct 
values populated from the DynaActionForm, but incorrect names:

org.apache.struts.taglib.html.BEAN[0].policycoverSumInsureds[0]
policycoverLess[0]

If I submit the form using an external-to-the-above=loop submit button, 
I get no errors, and the DynaActionForm bean is _not_ populated with the 
input text field, which is ignored.

If I attempt to use the "policycoverLess" submit button, struts bombs 
out with the following exception:

java.lang.ArrayIndexOutOfBoundsException
	at java.lang.reflect.Array.set(Native Method)
	at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:459)
	at 
org.apache.commons.beanutils.PropertyUtils.setIndexedProperty(PropertyUtils.java:1414)
	at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1013)
	at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
	at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1104)

Can anyone shed any light on what I am doing wrong, or can give me a 
piece of clear example code to show what I should be doing?

Regards,
Graham
--


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message