UI Spring MVC

 Basic concepts of Spring MVC.

Spring mvc is the heart of openmrs architecture currently used to ease the development of openmrs standard alone modules. Spring MVC is a java framework which is used to web applications.It follows the design pattern of Model - view -controller and also implements the basic feature of core spring frameworks like the inversion of controll(ioc), dependency injection.

The terminology for MVC

    1.The MODEL.The model encapsulates the application data commonly called POJO (means Plain Object Model) Pojo basically defines an entity class.forexample

           suppose your are creating a module that needs to have access to patient information. Assuming that the class is called Patient. 

             

Note forgetting setters methods and also creating constructor methods.  Most IDEs help us in getting things done without wasting much time . Am using eclipse IDE , so you open your class(patient class in this case)→ right click→ source→Generate getters and setters method. you can continue and provide constructor or to String method depending o n your needs.(Model handles the bussiness logic of the application)

2. The VIEW ,The view is responsible for rendering the model data and generates the html or jsp page that can be interpreted by the client(browser) or by the user.This

is where all the design is focussed.

3. The CONTROLLER  Controllers act like the mediator between view and model .It is responsible to controll the transimition of data between view and controller.Mapping is also done in controller classes of appropriate destination classes. Actually to my experience alot of work is done between controller and view because if you master these two , it becomes easy to render classes  and map them. We normally use the RequestMapping annotation and specify the url to which you want to map.

   forexample 

         

       @requestMapping("/url)

      public class Controller(){

     }

}

Note: You should include the @controller on top of class to show that it is a controller class and also to be able to call the specified url. 

J encourage to read about introduction to spring framework to have to learning materials. 


                     Any addition on this edit is highly appreciated and comments.(raff  need your comments or review of this if it is helpfull or what j need to add)