Announcement Announcement Module
Collapse
No announcement yet.
Spring MVC model refresh Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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.

      Comment

      Working...
      X