Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
08/18/08 12:05:28 (5 months ago)
Author:
machosry
Message:

address hierarchy: done with newPatientForm and patientDashboard yet to fix the drop down in patient.form

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/addresshierarchy/web/src/org/openmrs/module/addresshierarchy/web/controller/AddressLayoutPortletControlle.java

    r5288 r5302  
    1515 
    1616 
     17import java.io.IOException; 
     18import java.util.HashMap; 
     19import java.util.List; 
     20import java.util.Map; 
     21 
     22import javax.servlet.ServletException; 
     23import javax.servlet.http.HttpServletRequest; 
     24import javax.servlet.http.HttpServletResponse; 
     25 
    1726import org.apache.commons.logging.Log; 
    1827import org.apache.commons.logging.LogFactory; 
    19 import org.openmrs.module.addresshierarchy.layout.web.LayoutSupport; 
    20 import org.openmrs.module.addresshierarchy.layout.web.address.AddressSupport; 
     28import org.openmrs.api.context.Context; 
     29import org.openmrs.layout.web.LayoutSupport; 
     30import org.openmrs.layout.web.address.AddressSupport; 
     31import org.openmrs.module.addresshierarchy.AddressHierarchyService; 
     32import org.openmrs.web.controller.layout.LayoutPortletController; 
     33import org.springframework.validation.BindException; 
     34import org.springframework.web.servlet.ModelAndView; 
    2135 
    22 public class AddressLayoutPortletControlle extends LayoutPortletControlle { 
     36 
     37 
     38public class AddressLayoutPortletControlle extends LayoutPortletController { 
    2339         
    2440        private static Log log = LogFactory.getLog(AddressLayoutPortletControlle.class); 
     41         
     42        private AddressHierarchyService getService(){ 
     43        return (AddressHierarchyService)Context.getService(AddressHierarchyService.class); 
     44    } 
     45     
    2546         
    2647        protected String getDefaultsPropertyName() { 
     
    3455        protected LayoutSupport getLayoutSupportInstance() { 
    3556                log.debug("Getting address layout instance"); 
    36                 AddressSupport as = new AddressSupport(); 
    37                 return as.getInstance(); 
     57                //AddressSupport as = new AddressSupport(); 
     58                 
     59                System.out.println("in getlayoutsupportinstance"); 
     60                return AddressSupport.getInstance(); 
     61                 
    3862        } 
     63         
     64        public ModelAndView handleRequest(HttpServletRequest request, 
     65                        HttpServletResponse response) throws ServletException, IOException { 
     66                super.handleRequest(request, response); 
     67                Map<String, Object> model = new HashMap<String, Object>(); 
     68                String portletPath = "/module/addresshierarchy/portlets/addressLayout"; 
     69                return new ModelAndView(portletPath, "model", model); 
     70        } 
     71         
     72        //protected void populateModel(HttpServletRequest request, Map<String, Object> model) { 
     73                //super.populateModel(request, model); 
     74        //} 
     75         
     76        /* 
     77        protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { 
     78                 
     79                System.out.println("in processFormSubmission"); 
     80                Integer count = getService().getSizeOfPersonTable(); 
     81                 
     82                Integer formCount = Integer.valueOf(request.getParameter("count")); 
     83                 
     84                if(count == formCount){ 
     85                        Map<String, Object> model = new HashMap<String, Object>(); 
     86                        String portletPath = "/module/addresshierarchy/portlets/addressLayout"; 
     87                        return new ModelAndView(portletPath, "model", model); 
     88                } 
     89                         
     90                else 
     91                        return onSubmit(request,response,obj,errors); 
     92        } 
     93         
     94        protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { 
     95                 
     96                System.out.println("in onsubmit"); 
     97                 
     98                List x = getService().getLastRow(); 
     99                Object[] y = (Object[]) x.get(x.size()-1); 
     100                Integer id = Integer.valueOf(y[0].toString()); 
     101                Integer creator = Integer.valueOf(y[1].toString()); 
     102                Boolean voided = (Boolean) y[2]; 
     103                Integer voidedby; 
     104                if(voided) 
     105                        voidedby = Integer.valueOf(y[3].toString()); 
     106                else 
     107                        voidedby = null; 
     108                Map<String, Object> model = new HashMap<String, Object>(); 
     109                String portletPath = "/module/addresshierarchy/portlets/addressLayout"; 
     110                return new ModelAndView(portletPath, "model", model); 
     111                 
     112        }*/ 
     113         
     114         
    39115}