Wiki Spaces


Get Help from Others

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


Page tree
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

Version 1 Next »

OpenMRS uses dwr for AJAX. In a sentence, dwr converts java objects to javascript and vice versa.

DWR in core openmrs

Using DWR in a JSP page

<script src="<openmrs:contextPath/>/dwr/interface/DWRPatientService.js"></script>

DWRPatientService.findPatients("John", false, objectsFound);

function objectsFound(patients) {
  alert("There are " + patients.length + " patients named john");


Adding DWR into your module

Add to config.xml:

			<create creator="new" javascript="DWRMyModuleService">
				<param name="class" value="<at:var at:name="MODULE_PACKAGE" />.web.DWRMyModuleService"/>
				<include method="getAllLocations"/>

			import <at:var at:name="MODULE_PACKAGE" />.web.DWRMyModuleService;

Create this class:

public class DWRMyModuleService {

 public List<String> getAllLocations() {
     List<String> locationNames = new Vector<String>();
     for (Location loc : Context.getAllLocations()) {
     return locationNames;
  • No labels