/
DWR in OpenMRS
DWR in OpenMRS
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>
<script>
DWRPatientService.findPatients("John", false, objectsFound);
function objectsFound(patients) {
alert("There are " + patients.length + " patients named john");
}
</script>
Adding DWR into your module
Add to config.xml:
<dwr>
<allow>
<create creator="new" javascript="DWRMyModuleService">
<param name="class" value="@MODULE_PACKAGE@.web.DWRMyModuleService"/>
<include method="getAllLocations"/>
</create>
</allow>
<signatures>
<![CDATA[
import @MODULE_PACKAGE@.web.DWRMyModuleService;
DWRMyModuleService.getAllLocations();
]]>
</signatures>
</dwr>
Create this class:
public class DWRMyModuleService {
public List<String> getAllLocations() {
List<String> locationNames = new Vector<String>();
for (Location loc : Context.getAllLocations()) {
locationNames.add(loc.getName());
}
return locationNames;
}
Related content
Reference Application 2.x Developer Documentation
Reference Application 2.x Developer Documentation
Read with this
Check Digit Algorithm
Check Digit Algorithm
Read with this
Developer How-To Guide
Developer How-To Guide
Read with this
OpenMRS 2.0 Administrators Guide
OpenMRS 2.0 Administrators Guide
Read with this
Development Team
Development Team
Read with this
2.x core Patient Fragment step by step tutorial
2.x core Patient Fragment step by step tutorial
Read with this