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.dspace.app.webui.cris.controller.ProjectDetailsController.java

@Override
public ModelAndView handleDetails(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Map<String, Object> model = new HashMap<String, Object>();

    Project grant = extractProject(request);

    if (grant == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND, "Grant page not found");
        return null;
    }/*w  w w  .j a v  a2 s.com*/

    Context context = UIUtil.obtainContext(request);

    EPerson currentUser = context.getCurrentUser();

    if ((grant.getStatus() == null || grant.getStatus().booleanValue() == false)
            && !AuthorizeManager.isAdmin(context)) {

        if (currentUser != null || Authenticate.startAuthentication(context, request, response)) {
            // Log the error
            log.info(LogManager.getHeader(context, "authorize_error",
                    "Only system administrator can access to disabled researcher page"));

            JSPManager.showAuthorizeError(request, response,
                    new AuthorizeException("Only system administrator can access to disabled researcher page"));
        }
        return null;
    }

    if (AuthorizeManager.isAdmin(context)) {
        model.put("grant_page_menu", new Boolean(true));
    }

    ModelAndView mvc = null;

    try {
        mvc = super.handleDetails(request, response);
    } catch (RuntimeException e) {
        return null;
    }

    if (subscribeService != null) {
        boolean subscribed = subscribeService.isSubscribed(currentUser, grant);
        model.put("subscribed", subscribed);

    }

    request.setAttribute("sectionid", StatsConfig.DETAILS_SECTION);
    new DSpace().getEventService().fireEvent(new UsageEvent(UsageEvent.Action.VIEW, request, context, grant));

    mvc.getModel().putAll(model);
    mvc.getModel().put("project", grant);
    return mvc;
}

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

public ModelAndView addConcomitantMedication(HttpServletRequest request, Object cmd, Errors errors) {
    AbstractExpeditedAdverseEventInputCommand command = (AbstractExpeditedAdverseEventInputCommand) cmd;
    List<ConcomitantMedication> conmeds = command.getAeReport().getConcomitantMedications();

    ModelAndView modelAndView = new ModelAndView("ae/ajax/conMedFormSection");
    modelAndView.getModel().put("concomitantMedications", conmeds);
    int size = conmeds.size();
    Integer[] indexes = new Integer[] { size };
    modelAndView.getModel().put("indexes", indexes);

    ConcomitantMedication conmed = new ConcomitantMedication();
    conmed.setStartDate(new DateValue());
    conmed.setEndDate(new DateValue());
    command.getAeReport().addConcomitantMedication(conmed);

    return modelAndView;
}

From source file:easycare.web.user.UserController.java

/** Prepares model for 'new user' page, and return the view name. */
private ModelAndView showNewUserForm(HttpServletRequest request, ModelAndView modelAndView,
        NewUserForm newUserForm) {/*from   w w w .j  a  va 2 s  .c om*/
    EasyCareUserDetails currentUserDetails = securityService.getCurrentUserDetails();
    Set<Role> roles = roleService.findUserViewableRolesAndSubRoles(currentUserDetails);

    modelAndView.addObject(ROLES, roles);
    modelAndView.addObject(USER_FORM, newUserForm);
    modelAndView.addObject(LOCATIONS, userLocations());
    modelAndView.setViewName(NEW_USER_FORM);

    contactModelMaker.populateContactModel(modelAndView.getModel(), newUserForm.getContactInformation());

    // Keep pagination parameters
    PaginationHelper.addQueryStringAndPageNumberToSession(request, SESSION_KEY_PREFIX);

    return modelAndView;
}

From source file:com.thoughtworks.go.server.controller.GoConfigAdministrationControllerIntegrationTest.java

private void assertResponseMessage(ModelAndView mav, String message) {
    Json json = (Json) mav.getModel().get("json");
    new JsonTester(json).shouldContain("{ 'result' : '" + message + "' }");
}

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

public ModelAndView removeConcomitantMedication(HttpServletRequest request, Object cmd, Errors errors) {
    AbstractExpeditedAdverseEventInputCommand command = (AbstractExpeditedAdverseEventInputCommand) cmd;
    List<ConcomitantMedication> conmeds = command.getAeReport().getConcomitantMedications();
    ConcomitantMedication conMed = conmeds.get(command.getIndex());
    command.deleteAttribution(conMed);//from www . j a va  2  s.co  m
    conmeds.remove(conMed); //remove the element

    //create the indexes in reverse order
    int size = conmeds.size();
    Integer[] indexes = new Integer[size];
    for (int i = 0; i < size; i++) {
        indexes[i] = size - (i + 1);
    }

    ModelAndView modelAndView = new ModelAndView("ae/ajax/conMedFormSection");
    modelAndView.getModel().put("concomitantMedications", conmeds);
    modelAndView.getModel().put("indexes", indexes);

    return modelAndView;
}

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

public ModelAndView removePriorTherapy(HttpServletRequest request, Object cmd, Errors errors) {
    AbstractExpeditedAdverseEventInputCommand command = (AbstractExpeditedAdverseEventInputCommand) cmd;
    List<SAEReportPriorTherapy> priorTherapies = command.getAeReport().getSaeReportPriorTherapies();
    priorTherapies.remove(priorTherapies.get(command.getIndex())); //remove the element
    command.getPriorTherapyAgents().remove(command.getIndex()); //decrement the size of priortherapy agents by 1. 

    //create the indexes in reverse order
    int size = priorTherapies.size();
    Integer[] indexes = new Integer[size];
    for (int i = 0; i < size; i++) {
        indexes[i] = size - (i + 1);//from   w  ww. j  av a  2s.  co m
    }

    ModelAndView modelAndView = new ModelAndView("ae/ajax/priorTherapyFormSection");
    modelAndView.getModel().put("priorTherapies", priorTherapies);
    modelAndView.getModel().put("indexes", indexes);

    return modelAndView;
}

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

public ModelAndView addPreExistingCondition(HttpServletRequest request, Object cmd, Errors errors) {
    AbstractExpeditedAdverseEventInputCommand command = (AbstractExpeditedAdverseEventInputCommand) cmd;
    List<SAEReportPreExistingCondition> preConditions = command.getAeReport()
            .getSaeReportPreExistingConditions();

    ModelAndView modelAndView = new ModelAndView("ae/ajax/preExistingCondFormSection");
    modelAndView.getModel().put("preExistingConditions", preConditions);
    int size = preConditions.size();
    Integer[] indexes = new Integer[] { size };
    modelAndView.getModel().put("indexes", indexes);

    SAEReportPreExistingCondition preCondition = new SAEReportPreExistingCondition();
    //       preCondition.setPreExistingCondition(command.getPreExistingCondition());
    command.getAeReport().addSaeReportPreExistingCondition(preCondition);
    //       command.setPreExistingCondition(null);

    return modelAndView;
}

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

public ModelAndView addPriorTherapy(HttpServletRequest request, Object cmd, Errors errors) {
    AbstractExpeditedAdverseEventInputCommand command = (AbstractExpeditedAdverseEventInputCommand) cmd;
    List<SAEReportPriorTherapy> priorTherapies = command.getAeReport().getSaeReportPriorTherapies();

    ModelAndView modelAndView = new ModelAndView("ae/ajax/priorTherapyFormSection");
    modelAndView.getModel().put("priorTherapies", priorTherapies);
    int size = priorTherapies.size();
    Integer[] indexes = new Integer[] { size };
    modelAndView.getModel().put("indexes", indexes);

    SAEReportPriorTherapy priorTherapy = new SAEReportPriorTherapy();
    // priorTherapy.setPriorTherapy(command.getPriorTherapy());
    priorTherapy.setStartDate(new DateValue());
    priorTherapy.setEndDate(new DateValue());
    priorTherapy.setPriorTherapyAgentsInternal(new ArrayList<PriorTherapyAgent>());
    command.getAeReport().addSaeReportPriorTherapies(priorTherapy);
    // command.setPriorTherapy(null);
    command.getPriorTherapyAgents().add(null); //increment the element size

    return modelAndView;
}

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

public ModelAndView addPriorTherapyAgent(HttpServletRequest request, Object cmd, Errors errors) {
    AbstractExpeditedAdverseEventInputCommand command = (AbstractExpeditedAdverseEventInputCommand) cmd;
    SAEReportPriorTherapy priorTherapy = command.getAeReport().getSaeReportPriorTherapies()
            .get(command.getParentIndex());
    List<PriorTherapyAgent> priorTherapyAgents = priorTherapy.getPriorTherapyAgents();

    ModelAndView modelAndView = new ModelAndView("ae/ajax/priorTherapyAgentFormSection");
    modelAndView.getModel().put("priorTherapyAgents", priorTherapyAgents);
    modelAndView.getModel().put("parentIndex", command.getParentIndex());
    int size = priorTherapyAgents.size();
    Integer[] indexes = new Integer[] { size };
    modelAndView.getModel().put("indexes", indexes);

    //NOTE : firefox for some reason is chopping off the '[x]' in the variable name, so had to do this hoof-up in obtaining the chemoagent.
    PriorTherapyAgent agent = new PriorTherapyAgent();

    priorTherapy.addPriorTherapyAgent(agent);

    return modelAndView;
}

From source file:com.zb.app.web.controller.tour.TourController.java

@RequestMapping(value = "/userlist.htm")
public ModelAndView user(ModelAndView mav, TravelMemberQuery query, Integer page) {
    query.setPageSize(20);//ww  w.  j  a va 2 s. c o m
    query.setNowPageIndex(Argument.isNotPositive(page) ? 0 : page - 1);
    query.setcId(WebUserTools.getCid());

    PaginationList<TravelMemberDO> list = memberService.showMemberPagination(query, new DefaultIpageUrl());
    for (TravelMemberDO member : list) {
        if (StringUtils.isNotEmpty(member.getmPassword())) {
            member.setmPassword(EncryptBuilder.getInstance().decrypt(member.getmPassword()));
        }
    }

    mav.getModel().put(CustomVelocityLayoutView.USE_LAYOUT, "false");
    mav.addObject("memberList", list);
    mav.addObject("pagination", list.getQuery());
    mav.setViewName("/tour/customer/userlist");
    return mav;
}