Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Module portlets are defined in the omod/src/main/webapp/portlets folder.

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

<openmrs:portlet url="this.portlet" id="thisportlet" moduleId="ModuleID" />

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

where the actual portlet would be a file called this.jsp in the above folder.

Create a controller such as the following:

@Controller
@RequestMapping("**/this.portlet")
public class ThisPortletController extends PortletController {
    
    private static final Log log = LogFactory.getLog(ThisPortletController.class);
    @SuppressWarnings("unchecked")
    @Override
    protected void populateModel(HttpServletRequest request, Map<String, Object> model) {
// your code here
    }

and make sure the following line exists in your ModuleApplicationContext.xml file (it can be put just above the </beans> tag at the end:

    <context:component-scan base-package="org.openmrs.module.integration" />

The ThisModulesPortletController should extend PortletController and 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}

The code inside of a portlet shouldn't have to differ from a standard OpenMRS portletportlet, meaning that it looks exactly like a jsp (or part of a jsp).

  • No labels