Announcement Announcement Module
Collapse
No announcement yet.
Retrieve FBO in Controller annotated with @SessionAttributes Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retrieve FBO in Controller annotated with @SessionAttributes

    hi,
    I have a controller configured with annotations where the form-backing object should be stored in the session.

    To create the fbo I use the following code:
    Code:
    	
           @ModelAttribute
    	public userFBO setupFormObject(){
    		return new userFBO();
    	}
    In my eyes the fbo gets created new on every request (GET and POST) and is not restored from session. - Do I have to implement this by myself?

    Using the AbstractFormController this logic was performed in the getCommand-method.

  • #2
    If you use an @SessionAttributes at the class level the object is stored in and retrieved from the session.

    Comment


    • #3
      That's what I did:

      Code:
      @SessionAttributes(value = "userFBO")
      @Controller
      public class UserController {
      ...
      }
      So I have the following code in my controller:
      Code:
              .....
      
             @ModelAttribute
      	public userFBO setupFormObject(){
      		return new UserFBO();
      	}
      
             @RequestMapping(method = RequestMethod.POST)
             public @ModelAttribute("result") List<String> search(@ModelAttribute UserFBO criteria) {
             ....
             }
          ...
      In the documentation is stated that the setupFormObject is created on every request. - So when is the check for a session-formobject performed? And where are the values from the incoming request binded to this existing object?
      In the controller is there a possibility to access the object stored in the session?

      Comment


      • #4
        I strongly suggest that you read the reference guide.

        The method that you have specified used the object stored in the session or the initialy created one. If you created the correct jsp and input tags binding should happen if you want access to the results (exceptions etc.) include a BindingResult into your method signature.

        Comment

        Working...
        X