Can anyone point me to a working example of Struts2 indexed properties? I've
managed to get list indexing working: 
<s:checkbox name="users[%{#status.index}].administrator"... />
but haven't had any luck with the map style: 
<s:checkbox name="filter[%{#state.name}]"... />
(where state.getName returns a String), or the property-indexing style: 
<s:textfield name="beanList(%{#bean.id}).name" value="%{#bean.name}"/>
 (as described in the  http://cwiki.apache.org/WW/type-conversion.html wiki
). I tried running something similar to the wiki example (see attached
code), but when I submit my form I see an exception thrown for every attempt
to set a property (see below). Any insight or pointers would be greatly
appreciated.

The top of the exception stack:

ERROR 17:31:23,510 [com.opensymphony.xwork2.util.XWorkMethodAccessor] - An
unexpected exception occurred
ognl.OgnlException: Error getting property descriptor: null
        at
com.opensymphony.xwork2.util.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:92)
        at
com.opensymphony.xwork2.util.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:61)
        at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:846)
        at
com.opensymphony.xwork2.util.CompoundRootAccessor.callMethod(CompoundRootAccessor.java:196)
        at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:846)
        at ognl.ASTMethod.getValueBody(ASTMethod.java:73)
        at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
        at ognl.SimpleNode.getValue(SimpleNode.java:210)
        at ognl.ASTChain.setValueBody(ASTChain.java:168)
        at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
        at ognl.SimpleNode.setValue(SimpleNode.java:246)
        at ognl.Ognl.setValue(Ognl.java:476)
        at com.opensymphony.xwork2.util.OgnlUtil.setValue(OgnlUtil.java:186)
... etc, etc

The relevant piece of my struts.xml file:

    <action name="MyBean_show" method="show" class="MyBeanAction">
      <result>/jsp/MyBean.jsp</result>
    </action>
    <action name="MyBean" class="MyBeanAction">
      <result type="chain">MyBean_show</result>
    </action>

Here's the bean (as per wiki):
http://www.nabble.com/file/p11837653/MyBean.java MyBean.java 

Here's the action code:
http://www.nabble.com/file/p11837653/MyBeanAction.java MyBeanAction.java 

And the conversion properties:
http://www.nabble.com/file/p11837653/MyBean-conversion.properties
MyBean-conversion.properties 
-- 
View this message in context: 
http://www.nabble.com/Struts2%3A-list-and-map-indexing-tf4160457.html#a11837653
Sent from the Struts - User mailing list archive at Nabble.com.

Reply via email to