[Opensource] Bug in Controller when using multivalued lists
Raul DAVIDOVICH
R.DAVIDOVICH at caconcology.com
Fri Feb 27 05:14:26 PST 2004
Hello all,
I've been trying to use multiple select lists, and I found some issues on
it.
First, if I try to use request.getParameter("myList") I just get the first
selected item, but not the rest.
After some digging into Struts' doc, I found that for these cases I can
declare a form property as a String[] and it'll get populated with all the
values. I tried it and it works (for this I had to create an ActionForm
implementing StateForm and point to it on my config.xml file)
Next, I found that my ActionForm was beeing populated twice. First by
Struts, and then by Controller in the execute() method. I couldn't
understand why is it done like this..
This also introduced an issue because BeanUtils.populate(form,
req.getParameters()) tries to populate the form with an array of length 1
(normal since request parameters are simple strings)
I commenetd out the line and everything still works fine. But if someone
can tell me why is this done this way, I'll be happy to know about it.
finally, in loadStateForm() I had to change BeanUtils.populate(stateForm,
BeanUtils.describe(controllerForm)); to BeanUtils.populate(stateForm,
PropertyUtils.describe(controllerForm)); because BeanUtils.describe
converts all values to strings, whereas PropertyUtils.describe returns the
original type. Since we just deal with strings and only when using custom
forms, I think there is no danger on using it this way.
I'll be glad to receive any feedback, comments or questions on this.
Best regards,
---------------------------------------------------
Raul Davidovich
Responsable Informatique
Cvitkovic & Associés Consultants
(33) 1 45 15 40 68
(33) 1 45 15 40 41 Fax
-------------------------------------------------------
http://www.caconcology.com
More information about the Opensource
mailing list