File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes how to pass object from jsp to action class in struts??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to pass object from jsp to action class in struts???" Watch "how to pass object from jsp to action class in struts???" New topic
Author

how to pass object from jsp to action class in struts???

Mahanth Kumar
Greenhorn

Joined: Dec 10, 2007
Posts: 4
i need to pass an object(ArrayList) to an action class...

<html-el:hidden property = "arrayListOfEmpData" value = "${element.arrayList_Of_EmpData}"/>

<a href = "ExcelD.do?arrayList_Of_EmpData=arrayListOfEmpData">Report in Excel</a>

i tried the above but it throws the following exception...


exception

javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.IllegalArgumentException: argument type mismatch
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1656)
org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1551)
org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1580)
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:919)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You cannot create a single hidden field to pass an entire ArrayList of values. If you have an ArrayList of Strings, you can pass them by creating a hidden field for each element of the List and using indexed properties. See question 6 of the FAQ for more details on indexed properties.

A far easier way to do it would be just to put the ArrayList in session scope.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to pass object from jsp to action class in struts???