• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

populate a form

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note: Im using Spring for the view and buisiness layer, and Hibernate. But hibernate isn't important here. Im also really new to Spring.

I have created a form for adding items to my database, and it works. For that Im using a controller class that extends SimpleFormController.

I now want to reuse this controller and .jsp page for editing the verry same object as an editing page. In my mind the form would look almost exactly the same. So I changed the handleRequest method. And got the form successfully populated. But now I cant handle the submit part. My guess is that because I override the handleRequest method, the onsubmit method stops working i.e. aint being called. I havn't learned how to handle Log4j properly yet, so I dont know if onSubmit is being called or not, besides from the fact, knowing that nothing is being entered/changed into the DB.

This is what my Controller class looks like:





When this part gets called from my "index.jsp" view, it successfully populates the form with the information. But then I cannot submit it. Instead the same page is loaded as if the handleRequest is being called instead of onSubmit.
I know the onSubmit method works as Ive tested it before, when handleRequest wassnt implemented.


Can I please get suggestions on how to solve this? So that I can use this controller and .jsp page for both adding and editing an object.
Suggestions on how to solve this problem with another approach is also welcome.
Should I add any other information?
 
Al Coson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems I was looking for the formbackingObject method.. I didnt know it did what it did, but it does what I need to do, that is, populate my form.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic