You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jake Robb <jr...@sircon.com> on 2007/10/09 20:53:46 UTC

List properties in Struts 2

Hi everyone.  I’m new to the list.  :)

I’m working on a new Struts 2 application (my first).  I have quite a bit of experience with Struts 1.x.

I have a need to administer a set of rules, which are essentially name/value pairs.  The number of rules is dynamic.  I have a POJO class called Rule that has getters and setters for name and value.

On my Action, I have a List property with corresponding get and set methods:

>    public List<Rule> getRules() {
>        return rules;
>    }
>
>    public void setRules(List<Rule> rules_) {
>        rules = rules_;
>    }
>
>    private List<Rule> rules;

On my JSP, I have the following block of code:

>    <div id="results">
>        <s:iterator value="rules" status="status">
>            <div class="resultRow">
>                <div class="name">
>                    <s:textfield name="name" />
>                </div>
>                <div class="value">
>                    <s:textfield name="value" />
>                </div>
>            </div>
>        </s:iterator>
>    </div>

The page renders as expected, but when I submit the page, ParametersInterceptor logs the following error messages:

> [setParameters]: Unexpected Exception caught setting 'name' on 'class 
> com.blah.BlahAction: Error setting expression 'name' with value 
> '[Ljava.lang.String;@1fbc95c'>
>
> [setParameters]: Unexpected Exception caught setting 'value' on 'class
> com.blah.BlahAction: Error setting expression 'value' with value 
> '[Ljava.lang.String;@160cd93'>

What am I doing wrong?  I've tried several other approaches (indexed and mapped setters, and changing the name properties on the textfield tags accordingly), but I did some googling and found this: http://www.mail-archive.com/user@struts.apache.org/msg60905.html.  It seems to me that the approach I described above is the same as the one described in that message.

I'm thinking this is a typical greenie mistake, and I'm hoping someone here can set me straight.

Thanks,
Jake Robb