• 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

How do you load the initial command object populated for the initial index.jsp?

 
Bartender
Posts: 1938
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a simple Spring 3 MVC application, but when I changed the index.jsp to use the spring form tags (instead of regular HTML form controls), I then needed to have the form backing object loaded already or get the dreaded: "Neither BindingResult nor plain target object for bean name 'formObject' available as request attribute"

So, how do you get the initial form backing object initially populated so that, even if no values have been entered into the form variables (and they wouldn't have been since index.jsp is loading for the first time), you don't get any errors?

thanks.

mike
 
Ranch Hand
Posts: 32
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.Use annotation at class level for formObject:

@Configurable
public class FormObject {
//setter, getter
}
2.Use annotation at class level in Controller

@Controller
@SessionAttributes(value = { "formController" })
public class MyController(){

@ModelAttribute("formObject")
........

}

 
Mike London
Bartender
Posts: 1938
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I appreciate your reply, but it was too abbreviated for me to construct a working example.

However, I decided to just go to another page first and then when going to what used to be the index.jsp page, I then build the form backing object in the controller before that page loads.

thanks

mike
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic