Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 3525

Show
Ignore:
Timestamp:
03/03/08 14:02:14 (10 months ago)
Author:
bwolfe
Message:

Added some hints and comments to the basic module

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/basicmodule/metadata/moduleApplicationContext.xml

    r3249 r3525  
    1717         
    1818    <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> 
    2020                <property name="formView"><value>/module/@MODULE_ID@/basicmoduleForm</value></property> 
    2121                <property name="successView"><value>basicmoduleLink.form</value></property> 
  • openmrs-modules/basicmodule/web/module/basicmoduleForm.jsp

    r2428 r3525  
    55<h2><spring:message code="basicmodule.replace.this.link.name" /></h2> 
    66 
    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> 
    822 
    923<%@ include file="/WEB-INF/template/footer.jsp"%> 
  • openmrs-modules/basicmodule/web/src/org/openmrs/module/basicmodule/web/controller/BasicModuleFormController.java

    r2587 r3525  
    1515 
    1616import java.util.HashMap; 
     17import java.util.List; 
    1718import java.util.Map; 
    1819 
     
    2223import org.apache.commons.logging.Log; 
    2324import org.apache.commons.logging.LogFactory; 
     25import org.openmrs.Patient; 
     26import org.openmrs.api.context.Context; 
    2427import org.springframework.validation.BindException; 
    2528import org.springframework.validation.Errors; 
     
    2932 
    3033/** 
    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 
    3236 *  
    3337 */ 
     
    3741    protected final Log log = LogFactory.getLog(getClass()); 
    3842                     
     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     */ 
    3948    @Override 
    4049        protected Map<String, Object> referenceData(HttpServletRequest request, Object obj, Errors err) throws Exception { 
    4150 
     51        // this method doesn't return any extra data right now, just an empty map 
    4252                return new HashMap<String,Object>(); 
    4353        } 
    4454 
    4555 
     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         */ 
    4659        @Override 
    4760        protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object object, BindException exceptions) throws Exception {            
    4861        //HttpSession httpSession = request.getSession(); 
    4962 
    50         //MessageSourceAccessor msa = getMessageSourceAccessor(); 
    51                                  
    5263        return new ModelAndView(new RedirectView(getSuccessView())); 
    5364    } 
     
    5869     * java pojo. 
    5970     *  
     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     *  
    6074     * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) 
    6175     */ 
    6276    @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; 
    6588    } 
    6689