struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <ahardy.str...@cyberspaceroad.com>
Subject Re: iteration with indexed properties
Date Mon, 24 Apr 2006 08:31:12 GMT
you need to have an instantiated array of wrapper[] that is big enough 
to take what your HTML submits. If your action form is in the request, 
then wrappers[] will be null unless you instantiate it.

martin on 23/04/06 16:59, wrote:
> I've a problem with indexed properties inside an iteration. Some of the
> properties are rendered as a text-area and should be editable by the
> user. The rendering goes fine but if the user makes some changes, they
> are not committed to the form. Please take a look at the jsp/html/java
> snippets below.
> 
[snip]
> [jsp snippet]
> <logic:iterate id="wrapper" indexId="wrapperIndex" name="myForm"
> property="wrappers" scope="session">
>  <td class="">
>    <html:text name="wrapper" property="tip.scoreHome" indexed="true"
> size="1" maxlength="2" />&nbsp;:&nbsp;
>    <html:text name="wrapper" property="tip.scoreVisitor"
> indexed="true" size="1" maxlength="2" />
>  </td>
> </logic:iterate>
> 
> [rendered html]
>  <td class="">
>    <input type="text" name="wrapper[2].tip.guessedScoreHome"
> maxlength="2" size="1" value="23">&nbsp;:&nbsp;
>    <input type="text" name="wrapper[2].tip.guessedScoreVisitor"
> maxlength="2" size="1" value="">
>  </td>
> 
> [action form snippet]
>    public void setWrappers(GameTipWrapper[] wrappers) {
>        this.wrappers = wrappers;
>    }
> 
>    public GameTipWrapper getWrapper(int index) {
>        return wrappers[index];
>    }
> 
>    public void setWrapper(int index, GameTipWrapper wrapper) {
>        wrappers[index] = wrapper;
>    }

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


Mime
View raw message