You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Beuck, Torsten" <To...@otto.de> on 2001/08/09 13:27:49 UTC
select tag and indexed properties
Hi.
i have an ActionForm:
public class MyForm extends ActionForm {
...
public Collection getOptions(int index) { ... }
public Collection getLabels(int index) { ... }
public String[] getSelection(int index) { ... }
public void setSelection(int index, String[] value) { ... }
...
}
and the following JSP code:
<html:form action="testForm.do">
<logic:iterate name="test" property="list" id="current" indexId="ix">
...
<html:select multiple="true" name="form" property='<%= "selection["+ix+"]"
%>' size="3">
<html:options name="form" property='<%= "options["+ix+"]" %>'
labelName="form" labelProperty='<%= "labels["+ix+"]" %>'/>
</html:select>
...
</logic.iterate>
</html:form>
('test' is a bean that the list to iterate over; 'form' is the name of the
MyForm instance)
Everthing works fine but the setSelection(...) method. When i submit the
form i get:
java.lang.IllegalArgumentException: argument type mismatch
at java.lang.reflect.Method.invoke(Native Method)
at
org.apache.struts.util.PropertyUtils.setIndexedProperty(PropertyUtils.java:8
33)
at
org.apache.struts.util.PropertyUtils.setIndexedProperty(PropertyUtils.java:7
85)
at
org.apache.struts.util.PropertyUtils.setNestedProperty(PropertyUtils.java:90
2)
at
org.apache.struts.util.PropertyUtils.setProperty(PropertyUtils.java:932)
at org.apache.struts.util.BeanUtils.populate(BeanUtils.java:509)
at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:772)
at
org.apache.struts.action.ActionServlet.processPopulate(ActionServlet.java:20
61)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1563)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
I have to define a method
public void setSelection(int index, String value) { ... }
to get it working, but then i only get the first selected entry in the list
and not all. Is this a bug or did i something wrong?
Torsten Beuck
OTTO Versand
Abteilung IT-EW-WQ
Wandsbeker Str. 3 - 7
22172 Hamburg
Tel.: +49 40 6461 5351
Fax: +49 40 6464 5351
eMail: torsten.beuck@otto.de