• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

multibox functionality in struts

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Description of the problem:
I have a form which will display rows (Eg 100) with two columns ("vehicleDescription" and "leaseAmount" ). This form should display empty (unchecked) boxes for all the 100 rows on left side. This form has a "Delete" button. Whenever a user wants to delete some displayed rows, user selects check boxes associated with that rows. When the user clicks the Delete button, only those rows with checked boxes, should be retrieved in action class to be passed to delete method.



This is what I have in jsp page
<logic:iterate id = "vehicleLeaseListrowid" name="vehicleLeaseList"
scope = "request" type ="com.lvm.vehicle.server.data.VehiclesLeaseValueBean">
<tr>
<td><html:multibox property="selections"><bean:write name="vehicleLeaseListrowid" property="vehicleId"/></html:multibox></td>
<td class="lblBlk1"><bean:write name = "vehicleLeaseListrowid" property = "vehicleDescription"/></td>
<td class="lblBlk1"><bean:write name = "vehicleLeaseListrowid" property = "leaseAmount"/></td>
</tr>



This is what I have in actionform
private String[] selections = {};

public void setSelections(String[] selections){
this.selections = selections;
}

public String[] getSelections(){
return this.selections;
}



This is what I have in reset method
selections = null;



This is the exception error I am facing:
SRVE0026E: [Servlet Error]-[BeanUtils.populate]: java.lang.IllegalArgumentException: argument type mismatch
at java.lang.reflect.Method.invoke(Native Method)
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1650)
at org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1545)
at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1574)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:919)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726)


Please let me know if any more information is needed??
Can some body please help me with a solution??

Thank You
[ December 10, 2005: Message edited by: Sam Mites ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My experience is that an "argument type mismatch" error is the result of defining a property in your form bean that is not either a boolean, String, or String array. The field you've shown us looks OK. I'm wondering if there are any other <html:xxxx> tags in your forms that might be causing this problem. Does your form bean have any properties that are not of the above types? a Date perhaps?
 
Ranch Hand
Posts: 391
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right Merrill!!!

I wasted 2 days at my work place with the same error caused by a getter method that returs a date!!!
 
Sam Mites
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill,
I have few more properties which are decleared as Collection and FormFile needed for loading files. Will these datatypes affect?

Thank you
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me clarify a bit. You can put properties of any data type you want in your form bean. The thing you have to consider when you specify a property in an html:xxx tag is: "Can the Bean Utilities used by Struts convert this value to the appropriate type when it calls the getter or setter for the property?". If you have an html:text tag with property="myDate", and myDate is of type java.util.Date, then no, it can't convert it and you'll get an error. If it's of type int and the user happens to type an integer, then it will, but if the user happens to type a non-ingeger, then you'll get an error message. Obviously, in a tag where struts is expecting a collection, then a collection in your form bean is perfectly ok. Also, type FormFile is ok if you're using it with an html:file tag.

The point is just use common sense in recognizing that whatever gets put into the html form has to get converted to the type that is in the form bean.
 
this llama doesn't want your drama, he just wants this tiny ad for his mama
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic