Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 5300

Show
Ignore:
Timestamp:
08/18/08 02:20:11 (3 months ago)
Author:
r0bby
Message:

groovyforms: submit what I have so far.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/groovyforms/web/src/org/openmrs/module/groovyforms/web/servlet/GroovyFormsServlet.groovy

    r5180 r5300  
    2121import org.openmrs.module.groovyforms.util.GroovyFormsUtil 
    2222import org.openmrs.module.groovyforms.GroovyFormsContainer 
     23import org.openmrs.module.groovyforms.util.GroovyFormsClassUtil 
    2324 
    2425public class GroovyFormsServlet extends HttpServlet { 
     
    4243    @Override 
    4344    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
    44         def formId = request.getParameter("formid") 
    45         def form = GroovyFormsContainer.getForm(formId); 
    46         def f = GroovyFormsUtil.getControllerDirectory(formId).canonicalPath+"/${form.controllerClazzName}.groovy"          
    47         if(GroovyFormsClassUtil.isValidGroovy(formId,f)) { 
    48             def controller = getClassLoader().parseClass(f).newInstance() 
    49             controller.onSubmit form 
     45        def id = request.getParameter("formId") 
     46        def params = request.parameterMap 
     47        params.each { k,v -> log.info "$k -> $v" } 
     48        def model 
     49       if(GroovyFormsClassUtil.isValidGroovy(id,GroovyFormsUtil.getModelClazzFile(formId))) { 
     50           model = GroovyFormsClassUtil.getClazz(id,GroovyFormsUtil.getModelClazzFile(id).text).newInstance() 
     51           params.each {k,v -> 
     52               if(k != "formId") { 
     53                   model."$k" = v[0] 
     54               } 
     55           } 
     56       } 
     57        if(GroovyFormsClassUtil.isValidGroovy(formId,GroovyFormsUtil.getControllerClazzFile(formId))) { 
     58            def controller = GroovyFormsClassUtil.getClazz(id,GroovyFormsUtil.getControllerClazzFile(id).text) 
     59            controller.onSubmit model 
    5060        } 
    51          
    5261    } 
    5362 
     
    5766    @Override 
    5867    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
    59         PrintWriter out = response.writer 
    60         String formId = request.getParameter("formid") 
    61  
     68      doPost(request,response)  
    6269    } 
    6370