• 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

Using a DataBean Object in Struts Form bean

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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???
 
No, tomorrow we rule the world! With this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic