You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jeremiah Armstrong <ja...@posportal.com> on 2003/04/03 01:15:20 UTC

Index problems in select multiple=true

I have a question concerning the way ActionForm processes the following:

<select name="serialNumbers[123]" multiple="true" size="5">
 <option value="serialNumber1">serialNumber1</option>
 <option value="serialNumber2">serialNumber2</option>
 <option value="serialNumber3">serialNumber3</option>
 <option value="serialNumber4">serialNumber4</option>
 <option value="serialNumber5">serialNumber5</option>
 <option value="serialNumber6">serialNumber6</option>
</select>

In my ActionForm, I've written the following setter method:

public void setSerialNumbers(int poDetailId, String[] serialNumbers) {
	for (int i = 0; i < serialNumbers.length; i++) {
		System.out.println("poDetailId = " + poDetailId);
		System.out.println("serialNumbers[i] = " + serialNumbers[i]);
	}
}

For some reason, I always get the following error when posting the form:

java.lang.IllegalArgumentException: argument type mismatch
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.apache.commons.beanutils.PropertyUtils.setIndexedProperty(PropertyUtils.java:1435)
	at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1013)
	at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
	at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1096)
	at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1420)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:520)


I've searched through the mail archives looking for answers on why this is happening and how to get around it, but I can't seem to find a straight answer. Does anyone have a simple solution or at least an explanation for why this syntax is incorrect?

Thanks!

-- Jeremiah Armstrong

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