aspose file tools*
The moose likes Spring and the fly likes How do you load the initial command object populated for the initial index.jsp? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How do you load the initial command object populated for the initial index.jsp?" Watch "How do you load the initial command object populated for the initial index.jsp?" New topic
Author

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

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1075
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
Tekchand Prasad
Ranch Hand

Joined: Oct 20, 2005
Posts: 32
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
Ranch Hand

Joined: Jul 12, 2002
Posts: 1075
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How do you load the initial command object populated for the initial index.jsp?