This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Using a DataBean Object in Struts Form bean

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a struts form bean with set of String properties and a value DataBean(POJO). I included this data-bean in my form-bean to populate some business info. I was successful in loading the form with the info from the business data-bean. But when I try to submit the form, it throws error in BeanUtil opulate().

I know this is because of that data-bean being unable to be populated by the html:form, due to type mismatch. I saw in Struts FAQ about this - it suggested to use all properties as Strings.

I need your idea as "How we can successfully submit the jsp form(struts form) which has a value DataBean as property?"

Please help.

Thanks,
Ganesh
 
Ganesh Ramani
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Continuation of previous post: Below is the exception stack trace...

javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The general approach with Struts 1.x is to redefine the properties of your DataBean as String properties on your form. You then need some code that can populate your form from your DataBean and some code to populate a DataBean from your form. I typically add this code as methods on my form.

- Brent
 
Ganesh Ramani
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.

I have a form bean with ArrayList properties to populate a <html:select> field. I am able to submit that form successfully.

The same approach when i used in another form bean with an ArrayList property to populate a <html:select> and submit the form, its throwing the BeanUtil.populate() error.

What could be the reason???
 
I got this tall by not having enough crisco in my diet as a kid. This ad looks like it had plenty of shortening:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!