You just need a collection/map getter/setter in the action, you don't need an indexed setter.

http://struts.apache.org/2.x/docs/type-conversion.html#TypeConversion-CollectionandMapSupport

Dave

Ignacio de Córdoba wrote:
Hi there,
I am trying to migrate a form population module from struts1 to struts2 and
I am not sure if struts2 supports indexed/mapped value properties.

After reading OGNL docs I see that indexed properties are supported both
with ints and objects. I guess they refer just to "red" de properties, not
to set them in the action... so I am trying:

<s:textfield label="%{name}" name='fieldEntry[%{id}]' /> Where id is an
integer.

My action has the method:
        public void setFieldEntry(String fieldId, String value){}
(I've tried fieldID with int, Integer and String)
(Also I've tried String value and String[] value just in case it expects an
array of strings)

When I submit the form I get:

2009-02-11 02:14:49,195 WARN  [com.opensymphony.xwork2.ognl.OgnlValueStack]
Could not find property [struts.valueStack]
2009-02-11 02:14:49,198 INFO  [STDOUT] ognl.OgnlException: target is null
for setProperty(null, "1", [Ljava.lang.String;@410ef400)
2009-02-11 02:14:49,198 INFO  [STDOUT]  at
ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651)
2009-02-11 02:14:49,198 INFO  [STDOUT]  at
ognl.ASTProperty.setValueBody(ASTProperty.java:101)
2009-02-11 02:14:49,199 INFO  [STDOUT]  at
ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
2009-02-11 02:14:49,199 INFO  [STDOUT]  at
ognl.SimpleNode.setValue(SimpleNode.java:246)
2009-02-11 02:14:49,199 INFO  [STDOUT]  at
ognl.ASTChain.setValueBody(ASTChain.java:172)
2009-02-11 02:14:49,199 INFO  [STDOUT]  at
ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
2009-02-11 02:14:49,199 INFO  [STDOUT]  at
ognl.SimpleNode.setValue(SimpleNode.java:246)
2009-02-11 02:14:49,199 INFO  [STDOUT]  at ognl.Ognl.setValue(Ognl.java:476)
2009-02-11 02:14:49,199 INFO  [STDOUT]  at
com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:192)

Thanks for any help



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

Reply via email to