| Author |
Using a DataBean Object in Struts Form bean
|
Ganesh Ramani
Greenhorn
Joined: Aug 07, 2007
Posts: 20
|
|
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
Joined: Aug 07, 2007
Posts: 20
|
|
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
Joined: Feb 08, 2006
Posts: 948
|
|
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
Joined: Aug 07, 2007
Posts: 20
|
|
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???
|
 |
 |
|
|
subject: Using a DataBean Object in Struts Form bean
|
|
|