This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using a DataBean Object in Struts Form bean

 
Ganesh Ramani
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)
 
Brent Sterling
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???
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic