• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Use 2Dimensional array for <html:select> fields with same name in struts Action Form&html form?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am using struts 1.1 then

1) My jsp page contains following tag:

<html:select property="color" multiple="true">
<option value="1">red</option>
<option value="2">green</option>
<option value="3">white</option>
<option value="4">black</option>
</html:select>
<html:select property="color" multiple="true">
<option value="5">black</option>
<option value="6">Yellow</option>
<option value="7">silver</option>
</html:select>



2) define setter and getter for those Fields in ActionForm of Struts:

public void setColor(Object[][] color){
this.color=color;
}

public Object[][] getColor(){
return this.color;
}

3) While submit from jsp, the following error occured:

java.lang.IllegalArgumentException: array element type mismatch
at java.lang.reflect.Array.set(Native Method)
at org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBea
n.java:464)
at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.
java:986)
at org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.jav
a:811)


Thanks & Regards,
Prakash

 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to use indexed properties. There are many discussions and examples in this forum.
reply
    Bookmark Topic Watch Topic
  • New Topic