OpenMRS Worldwide Summit is fast approaching!

#OMRS15, the 1st OpenMRS Worldwide Summit, is 8-14 December. Registration is open & session ideas are being accepted. More information:

Wiki Spaces


Get Help from Others

Q&A: Ask OpenMRS »
Discussion: OpenMRS Talk »
Real-Time: IRC Chat


Skip to end of metadata
Go to start of metadata

Create a module portlet controller

Module portlet controllers, along with form controllers, are typically put in the omod/src/main/java/web.controller folder and have names ending with PortletController.  Portlet controllers should extend PortletController. If there are actions that need to be taken when the portlet is referenced, override the populateModel method.  Any property added to the model in the populateModule method is available UNDER the "model" property.  So if you add "myvar" to the model object, in your portlet jsp you access it with ${model.myvar}.  Here is an example:

Make sure the following line exists in your ModuleApplicationContext.xml file, substituting your module name for ModuleID.  It typically is put just above the </beans> tag at the end.

Create the module portlet jsp

Module portlets are defined in the omod/src/main/webapp/portlets folder.  In our example, the portlet would be named this.jsp.  The code inside of a portlet shouldn't have to differ from a standard OpenMRS portlet, meaning that it looks exactly like a jsp (or part of a jsp).

Use the portlet in another jsp page

Portlets are included in a jsp by using the following tag:

Note that you must specify moduleId="...", which differs from using a portlet in core code.


  1. Post Spring 2.5, we don't need the wiring to be manual(inclusion in the xml files). In our custom portlet controller we need to include annotation such as 


    This will automatically wire the controller and the portlet.
  2. I think an Introduction of what Module Portlets are (in the OpenMRS context) should be given beginning of this document