Results 1 to 3 of 3

Thread: Spring MVC model refresh

Hybrid View

  1. #1
    Join Date
    Jan 2012
    Posts
    16

    Default Spring MVC model refresh

    Hi guys,

    we are hust in train of doing our first Spring MVC steps, I have a very very basic question and hopefully someone of the seniors can answer: how do you treat modek refreshes? Sya we have a request (e.g. form submit via POST) which is caught by our controller and somehow modifies the model:

    @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    @RequestMapping(method=RequestMethod.POST)
    public ModelAndView loginUser(HttpServletRequest request,
    HttpServletResponse response,
    @RequestBody User user)
    {
    ourModel.addObject("username","bli bla blub");
    return ourModel;
    }

    How do we inform the view about these changes as we have several objects there bound do ${username} but will not display the username, so my terrible guess is that Spring MVC only pushes changes to the view in case of URL changes...can anybody confirm? If so the whole Spring MVC approach is pretty much worthless as synchronization between model and view in terms of views watching the model and displaying changes is not provided - but maybe somenone of you guys knows how to resolve our issue...

    thanx in advance, FLorian;

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    I suggest a read on MVC especially as used in web applications. There is no way (well not entirely true) to get data pushed from the server (there are some techniques but basically all are pulls not pushes from the server). Also using a singleton model for your application isn't really the way to go.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Quote Originally Posted by Marten Deinum View Post
    I suggest a read on MVC especially as used in web applications. There is no way (well not entirely true) to get data pushed from the server (there are some techniques but basically all are pulls not pushes from the server). Also using a singleton model for your application isn't really the way to go.
    Excuse me, could you explain it a little bit more that? in my case, I have a formController extending the SimpleFormController, but when I save the entity information linked into the form in one place of my application, this isn't being refreshed in the rest of parts of the application although they share the same extended formController and I checked the entity is up of date. For that, I need refresh the model.

    In fact I could do a singleton instance of this formCotroller but this is going to be share for any user of my application. and this don't have many sense in my opinion.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •