Example usage for org.springframework.web.servlet ModelAndView getModel

List of usage examples for org.springframework.web.servlet ModelAndView getModel

Introduction

In this page you can find the example usage for org.springframework.web.servlet ModelAndView getModel.

Prototype

public Map<String, Object> getModel() 

Source Link

Document

Return the model map.

Usage

From source file:org.zkoss.zk.grails.web.ZULUrlMappingsFilter.java

private boolean renderViewForUrlMappingInfo(HttpServletRequest request, HttpServletResponse response,
        UrlMappingInfo info, String viewName) {
    if (viewResolver != null) {
        View v;//from   w w w  . jav a 2s . co  m
        try {
            // execute pre handler interceptors
            for (HandlerInterceptor handlerInterceptor : handlerInterceptors) {
                if (!handlerInterceptor.preHandle(request, response, this))
                    return false;
            }

            // execute post handlers directly after, since there is no controller. The filter has a chance to modify the view at this point;
            final ModelAndView modelAndView = new ModelAndView(viewName);
            for (HandlerInterceptor handlerInterceptor : handlerInterceptors) {
                handlerInterceptor.postHandle(request, response, this, modelAndView);
            }

            v = WebUtils.resolveView(request, info, modelAndView.getViewName(), viewResolver);
            v.render(modelAndView.getModel(), request, response);

            // after completion
            for (HandlerInterceptor handlerInterceptor : handlerInterceptors) {
                handlerInterceptor.afterCompletion(request, response, this, null);
            }
        } catch (Throwable e) {
            // let the sitemesh filter re-run for the error
            reapplySitemesh(request);
            for (HandlerInterceptor handlerInterceptor : handlerInterceptors) {
                try {
                    handlerInterceptor.afterCompletion(request, response, this,
                            e instanceof Exception ? (Exception) e
                                    : new GroovyPagesException(e.getMessage(), e));
                } catch (Exception e1) {
                    UrlMappingException ume = new UrlMappingException(
                            "Error executing filter after view error: " + e1.getMessage() + ". Original error: "
                                    + e.getMessage(),
                            e1);
                    filterAndThrow(ume);
                }
            }
            UrlMappingException ume = new UrlMappingException(
                    "Error mapping onto view [" + viewName + "]: " + e.getMessage(), e);
            filterAndThrow(ume);
        }
    }
    return true;
}

From source file:gov.nih.nci.cabig.caaers.web.participant.SubjectMedHistoryTab.java

/**
 * Add an item to the collection through AJAX
 * *//* www  .  j  a  v a 2s .com*/
public ModelAndView addMetastaticDiseaseSite(HttpServletRequest request, Object cmd, Errors errors) {
    ParticipantInputCommand command = (ParticipantInputCommand) cmd;
    ModelAndView modelAndView = new ModelAndView("par/ajax/metastaticDiseaseSiteFormSection");
    List<StudyParticipantMetastaticDiseaseSite> sites = command.getAssignment().getDiseaseHistory()
            .getMetastaticDiseaseSites();
    modelAndView.getModel().put("metastaticDiseaseSites", sites);
    int size = sites.size();
    Integer[] indexes = new Integer[] { size };
    modelAndView.getModel().put("indexes", indexes);

    // AnatomicSite site = command.getMetastaticDiseaseSite();
    StudyParticipantMetastaticDiseaseSite metastaticSite = new StudyParticipantMetastaticDiseaseSite();
    // metastaticSite.setCodedSite(site);
    command.getAssignment().getDiseaseHistory().addMetastaticDiseaseSite(metastaticSite);
    // command.setMetastaticDiseaseSite(null);

    return modelAndView;
}

From source file:gov.nih.nci.cabig.caaers.web.participant.EditParticipantTab.java

public ModelAndView removeSystemIdentifier(HttpServletRequest request, Object cmd, Errors error) {
    Map<String, Boolean> map = new HashMap<String, Boolean>();
    ModelAndView modelAndView = new ModelAndView(getAjaxViewName(request), map);

    ParticipantInputCommand command = (ParticipantInputCommand) cmd;
    List<SystemAssignedIdentifier> list = command.getParticipant().getSystemAssignedIdentifiers();
    list.remove(list.get(command.getIndex()));

    // update the array of remainning indexes after deleting
    int size = list.size();
    Integer[] indexes = new Integer[size];
    for (int i = 0; i < size; i++) {
        indexes[i] = i;//from  w  w  w. j ava2  s.  com
    }

    modelAndView.getModel().put("indexes", indexes);
    modelAndView.getModel().put("remove", "remove");
    return modelAndView;
}

From source file:gov.nih.nci.cabig.caaers.web.ae.StudyInterventionsTab.java

public ModelAndView addAgent(HttpServletRequest request, Object command, Errors errors) {
    ExpeditedAdverseEventInputCommand cmd = (ExpeditedAdverseEventInputCommand) command;
    CourseAgent ca = new CourseAgent();
    List<CourseAgent> agents = cmd.getAeReport().getTreatmentInformation().getCourseAgents();
    cmd.getAeReport().getTreatmentInformation().addCourseAgent(ca);
    ca.getTreatmentInformation().setReport(cmd.getAeReport());
    ModelAndView modelAndView = new ModelAndView("ae/ajax/courseAgentFormSection");
    modelAndView.getModel().put("agents", agents);
    modelAndView.getModel().put("indexes", new Integer[] { agents.size() - 1 });
    return modelAndView;
}

From source file:gov.nih.nci.cabig.caaers.web.ae.StudyInterventionsTab.java

public ModelAndView addDevice(HttpServletRequest request, Object command, Errors errors) {
    ExpeditedAdverseEventInputCommand cmd = (ExpeditedAdverseEventInputCommand) command;
    MedicalDevice md = new MedicalDevice();
    List<MedicalDevice> devices = cmd.getAeReport().getMedicalDevices();
    cmd.getAeReport().addMedicalDevice(md);
    md.setReport(cmd.getAeReport());//from   w w  w  .  ja  v a 2s .co m
    ModelAndView modelAndView = new ModelAndView("ae/ajax/medicalDeviceFormSection");
    modelAndView.getModel().put("devices", devices);
    modelAndView.getModel().put("indexes", new Integer[] { devices.size() - 1 });
    return modelAndView;
}

From source file:gov.nih.nci.cabig.caaers.web.participant.EditParticipantTab.java

public ModelAndView removeOrganizationIdentifier(HttpServletRequest request, Object cmd, Errors error) {
    Map<String, Boolean> map = new HashMap<String, Boolean>();
    ModelAndView modelAndView = new ModelAndView(getAjaxViewName(request), map);

    ParticipantInputCommand command = (ParticipantInputCommand) cmd;
    List<OrganizationAssignedIdentifier> list = command.getParticipant().getOrganizationIdentifiers();
    list.remove(list.get(command.getIndex()));

    // update the array of remainning indexes after deleting
    int size = list.size();
    Integer[] indexes = new Integer[size];
    for (int i = 0; i < size; i++) {
        indexes[i] = i;//from w  ww.j  ava2  s.c  o m
    }

    modelAndView.getModel().put("indexes", indexes);
    modelAndView.getModel().put("remove", "remove");
    return modelAndView;
}

From source file:gov.nih.nci.cabig.caaers.web.ae.StudyInterventionsTab.java

public ModelAndView addSurgery(HttpServletRequest request, Object command, Errors errors) {
    ExpeditedAdverseEventInputCommand cmd = (ExpeditedAdverseEventInputCommand) command;
    SurgeryIntervention si = new SurgeryIntervention();
    List<SurgeryIntervention> surgeries = cmd.getAeReport().getSurgeryInterventions();
    cmd.getAeReport().addSurgeryIntervention(si);
    si.setReport(cmd.getAeReport());/* ww  w  . j  a  va2s .c om*/
    ModelAndView modelAndView = new ModelAndView("ae/ajax/surgeryInterventionFormSection");
    modelAndView.getModel().put("surgeries", surgeries);
    modelAndView.getModel().put("indexes", new Integer[] { surgeries.size() - 1 });
    return modelAndView;
}

From source file:gov.nih.nci.cabig.caaers.web.ae.StudyInterventionsTab.java

public ModelAndView addDietary(HttpServletRequest request, Object command, Errors errors) {
    ExpeditedAdverseEventInputCommand cmd = (ExpeditedAdverseEventInputCommand) command;
    DietarySupplementIntervention si = new DietarySupplementIntervention();
    List<DietarySupplementIntervention> dietaries = cmd.getAeReport().getDietaryInterventions();
    cmd.getAeReport().addDietarySupplementalIntervention(si);
    si.setReport(cmd.getAeReport());/*  w w w .  j a  v a2  s  .  c  o  m*/
    ModelAndView modelAndView = new ModelAndView("ae/ajax/dietaryInterventionFormSection");
    modelAndView.getModel().put("dietaries", dietaries);
    modelAndView.getModel().put("indexes", new Integer[] { dietaries.size() - 1 });
    return modelAndView;
}

From source file:gov.nih.nci.cabig.caaers.web.ae.StudyInterventionsTab.java

public ModelAndView addGenetic(HttpServletRequest request, Object command, Errors errors) {
    ExpeditedAdverseEventInputCommand cmd = (ExpeditedAdverseEventInputCommand) command;
    GeneticIntervention si = new GeneticIntervention();
    List<GeneticIntervention> genetics = cmd.getAeReport().getGeneticInterventions();
    cmd.getAeReport().addGeneticIntervention(si);
    si.setReport(cmd.getAeReport());//  ww w  .j  av a2 s .co m
    ModelAndView modelAndView = new ModelAndView("ae/ajax/geneticInterventionFormSection");
    modelAndView.getModel().put("genetics", genetics);
    modelAndView.getModel().put("indexes", new Integer[] { genetics.size() - 1 });
    return modelAndView;
}

From source file:gov.nih.nci.cabig.caaers.web.ae.StudyInterventionsTab.java

public ModelAndView addOtherAE(HttpServletRequest request, Object command, Errors errors) {
    ExpeditedAdverseEventInputCommand cmd = (ExpeditedAdverseEventInputCommand) command;
    OtherAEIntervention si = new OtherAEIntervention();
    List<OtherAEIntervention> otherAEInterventions = cmd.getAeReport().getOtherAEInterventions();
    cmd.getAeReport().addOtherAEIntervention(si);
    si.setReport(cmd.getAeReport());// w w  w.  j a v  a2  s . c  om
    ModelAndView modelAndView = new ModelAndView("ae/ajax/otherAEInterventionFormSection");
    modelAndView.getModel().put("otherAEInterventions", otherAEInterventions);
    modelAndView.getModel().put("indexes", new Integer[] { otherAEInterventions.size() - 1 });
    return modelAndView;
}