Announcement Announcement Module
Collapse
No announcement yet.
Controllers Life Cycle. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Controllers Life Cycle.

    Hi,
    I would like to know who is responsible for calling the different methods inside a controller.
    I understand that the dispatcher servlet receives the request then using the handler mapping decides which controller should handle the request and then the controller carries on its actions and return a model and view to the dispatcher servlet.
    I could also understand that the different methods of a certain controller are excuted in a certain sequence.
    What I want to know is who is responsible for excuting these methods in sequence.

    I also want to know, if I'm using a simpleFormController, I could either override the doSubmitAction method or the onSubmit method.
    Who is responsible which one of them is present and should be excuted?
    What would happen if both methods were overridden?

    Thanks in Advance.
    Sherihan.

  • #2
    The methods are all called from the respective controllers themselves in a template/strategy fashion. There's no outside 'something' that determines the sequence in which they're called.

    The controller interface has a handle method, every controller down the hierarchy adds behavior specific to the controller and calls the added methods.

    regards,
    Alef Arendsen

    Comment


    • #3
      If I remember correctly, the Java Doc does a very good job of explaining this, specifically for AbstractFormController and SimpleFormController.


      Keller

      Comment


      • #4
        Hi Alef,
        First of all thanks for the reply.
        I would like to know what is meant by the template/strategy model u mentioned in your post.

        I would like also to know what is the handle method that each controller has and what is its exact function.

        Thanks in Advance.
        Sherihan.

        Comment


        • #5
          I suggest you have a look at the design patterns section of the c2 wiki, specifically the strategy (http://c2.com/cgi/wiki?StrategyPattern) and the Template method (http://c2.com/cgi/wiki?TemplateMethodPattern). You could also buy yourself a copy of 'Design Patterns' (http://www.amazon.com/exec/obidos/AS...939520-1328653) by Gamme, Helm et. al. Required reading for each and every programmer.

          The handle() method is responsible for taking care of the request and coming up with an appropriate ModelAndView. This method is part of the of the Controller interface and by using Strategies and Template Methods finer-grained behavior is added in the controllers that extend it.

          Keller is right about the JavaDoc, it explains things pretty well also.

          regards,
          Alef Arendsen

          Comment

          Working...
          X