Changeset 3525
- Timestamp:
- 03/03/08 14:02:14 (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs-modules/basicmodule/metadata/moduleApplicationContext.xml
r3249 r3525 17 17 18 18 <bean id="basicmoduleFormController" class="@MODULE_PACKAGE@.web.controller.BasicModuleFormController"> 19 <property name="commandName"><value> basicmoduleFormObject</value></property>19 <property name="commandName"><value>thePatientList</value></property> 20 20 <property name="formView"><value>/module/@MODULE_ID@/basicmoduleForm</value></property> 21 21 <property name="successView"><value>basicmoduleLink.form</value></property> openmrs-modules/basicmodule/web/module/basicmoduleForm.jsp
r2428 r3525 5 5 <h2><spring:message code="basicmodule.replace.this.link.name" /></h2> 6 6 7 Hello, world! 7 <br/> 8 <table> 9 <tr> 10 <th>Patient Id</th> 11 <th>Name</th> 12 <th>Identifier</th> 13 </tr> 14 <c:forEach var="patient" items="${thePatientList}"> 15 <tr> 16 <td>${patient.patientId}</td> 17 <td>${patient.personName}</td> 18 <td>${patient.patientIdentifier}</td> 19 </tr> 20 </c:forEach> 21 </table> 8 22 9 23 <%@ include file="/WEB-INF/template/footer.jsp"%> openmrs-modules/basicmodule/web/src/org/openmrs/module/basicmodule/web/controller/BasicModuleFormController.java
r2587 r3525 15 15 16 16 import java.util.HashMap; 17 import java.util.List; 17 18 import java.util.Map; 18 19 … … 22 23 import org.apache.commons.logging.Log; 23 24 import org.apache.commons.logging.LogFactory; 25 import org.openmrs.Patient; 26 import org.openmrs.api.context.Context; 24 27 import org.springframework.validation.BindException; 25 28 import org.springframework.validation.Errors; … … 29 32 30 33 /** 31 * This controller backs and saves the basic module settings 34 * This controller backs the /web/module/basicmoduleForm.jsp page. 35 * This controller is tied to that jsp page in the /metadata/moduleApplicationContext.xml file 32 36 * 33 37 */ … … 37 41 protected final Log log = LogFactory.getLog(getClass()); 38 42 43 /** 44 * Returns any extra data in a key-->value pair kind of way 45 * 46 * @see org.springframework.web.servlet.mvc.SimpleFormController#referenceData(javax.servlet.http.HttpServletRequest, java.lang.Object, org.springframework.validation.Errors) 47 */ 39 48 @Override 40 49 protected Map<String, Object> referenceData(HttpServletRequest request, Object obj, Errors err) throws Exception { 41 50 51 // this method doesn't return any extra data right now, just an empty map 42 52 return new HashMap<String,Object>(); 43 53 } 44 54 45 55 56 /** 57 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException) 58 */ 46 59 @Override 47 60 protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object object, BindException exceptions) throws Exception { 48 61 //HttpSession httpSession = request.getSession(); 49 62 50 //MessageSourceAccessor msa = getMessageSourceAccessor();51 52 63 return new ModelAndView(new RedirectView(getSuccessView())); 53 64 } … … 58 69 * java pojo. 59 70 * 71 * The type can be set in the /config/moduleApplicationContext.xml file or it can be just 72 * defined by the return type of this method 73 * 60 74 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) 61 75 */ 62 76 @Override 63 protected Object formBackingObject(HttpServletRequest request) throws Exception { 64 return "REPLACE ME"; 77 protected List<Patient> formBackingObject(HttpServletRequest request) throws Exception { 78 79 // get all patients that have an identifier "1234" 80 // see http://resources.openmrs.org/doc/index.html?org/openmrs/api/PatientService.html for 81 // a list of all PatientService methods 82 List<Patient> patients = Context.getPatientService().findPatients("1234", false); 83 84 // this object will be made available to the jsp page under the variable name 85 // that is defined in the /metadata/moduleApplicationContext.xml file 86 // under the "commandName" tag 87 return patients; 65 88 } 66 89