OpenMRS uses dwr for AJAX. In a sentence, dwr converts java objects to javascript and vice versa.
DWR in core openmrs
- httphttps://svngithub.openmrs.org/openmrs/trunk/webcom/OpenMRS/openmrs-core/blob/master/webapp/src/main/webapp/WEB-INF/dwr.xml
Using DWR in a JSP page
Code Block |
---|
<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> |
...
Code Block |
---|
<dwr> <allow> <create creator="new" javascript="DWRMyModuleService"> <param name="class" value="<at:var at:name="MODULE_PACKAGE" />@MODULE_PACKAGE@.web.DWRMyModuleService"/> <include method="getAllLocations"/> </create> </allow> <signatures> <![CDATA[ import <at:var at:name="MODULE_PACKAGE" />@MODULE_PACKAGE@.web.DWRMyModuleService; DWRMyModuleService.getAllLocations(); ]]> </signatures> </dwr> |
...