Example usage for org.springframework.web.servlet.view RedirectView RedirectView

List of usage examples for org.springframework.web.servlet.view RedirectView RedirectView

Introduction

In this page you can find the example usage for org.springframework.web.servlet.view RedirectView RedirectView.

Prototype

public RedirectView(String url) 

Source Link

Document

Create a new RedirectView with the given URL.

Usage

From source file:org.openmrs.module.conceptsearch.web.controller.ConceptNameTagFormController.java

/**
 * The onSubmit function receives the form/command object that was modified by the input form
 * and saves it to the db//from ww  w.  ja  v  a  2s  .c o m
 * 
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 */
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
        BindException errors) throws Exception {

    HttpSession httpSession = request.getSession();

    String view = getFormView();

    if (Context.isAuthenticated()) {
        ConceptNameTag nameTag = (ConceptNameTag) obj;
        Context.getConceptService().saveConceptNameTag(nameTag);
        view = getSuccessView();
        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "ConceptNameTag.saved");
    }

    return new ModelAndView(new RedirectView(view));
}

From source file:de.otto.mongodb.profiler.web.OpProfileController.java

@RequestMapping(method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
public View showOpProfiles(@PathVariable("connectionId") final String connectionId,
        @PathVariable("databaseName") final String databaseName,
        final UriComponentsBuilder uriComponentsBuilder) throws ResourceNotFoundException {

    final String uri = uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}")
            .fragment("OpProfiles").buildAndExpand(connectionId, databaseName).toUriString();

    return new RedirectView(uri);
}

From source file:fr.hoteia.qalingo.web.mvc.controller.security.LoginController.java

@RequestMapping(FoUrls.LOGIN_CHECK_URL)
public ModelAndView loginCheck(final HttpServletRequest request, final Model model) throws Exception {
    ModelAndView modelAndView = new ModelAndView(FoUrls.LOGIN.getVelocityPage());

    final Customer currentCustomer = requestUtil.getCurrentCustomer(request);
    if (currentCustomer != null) {
        final String urlRedirect = urlService.generateUrl(FoUrls.HOME, requestUtil.getRequestData(request));
        return new ModelAndView(new RedirectView(urlRedirect));
    }// w  w w.  ja  va 2s . c om

    return modelAndView;
}

From source file:eu.jasha.demo.sbtfragments.CityController.java

@RequestMapping(value = PATH_ID, method = POST)
public RedirectView updateCity(@PathVariable(ID) String id, @ModelAttribute("city") City city) {
    LOG.info("Updating city {}", id);

    cityDao.update(city);//ww  w.  ja  v  a  2  s . co m
    return new RedirectView("");
}

From source file:net.mindengine.oculus.frontend.web.controllers.trm.tasks.AddTaskDependenciesController.java

@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    verifyPermissions(request);//from   w  w w . java2s  .  c o  m
    Long taskId = Long.parseLong(request.getParameter("taskId"));

    TrmTask task = trmDAO.getTask(taskId);
    if (task == null)
        throw new UnexistentResource("Task with id = " + taskId + " doesn't exist");

    User user = getUser(request);
    if (!user.getId().equals(task.getUserId())) {
        throw new PermissionDeniedException("You are not allowed to change tasks of other users");
    }

    /*
     * Fetching task dependencies in order to check if there are the same dependencies as in request.
     * We should avoid dependency coupling.
     */
    Collection<TrmTaskDependency> dependencies = trmDAO.getTaskDependencies(taskId);

    String refTaskIds[] = request.getParameter("refTaskIds").split(",");

    for (String strRefTaskId : refTaskIds) {
        /*
         * As each task is sent in request starting with 't' letter we need to remove it from here 
         */
        Long refTaskId = Long.parseLong(strRefTaskId.substring(1));
        if (!refTaskId.equals(taskId)) {
            if (!contains(dependencies, refTaskId)) {
                trmDAO.createTaskDependency(taskId, refTaskId);
            }
        }
    }

    return new ModelAndView(new RedirectView("../grid/edit-task?id=" + taskId));
}

From source file:org.pac4j.test.cas.controller.CallbackController.java

@SuppressWarnings("unchecked")
@Override//w w w. j  a v  a  2s.  c  om
protected ModelAndView handleRequestInternal(final HttpServletRequest request,
        final HttpServletResponse response) {

    final WebContext context = new J2EContext(request, response);

    final Client<CasCredentials, CasProfile> client = this.clients.findClient(context);

    CasCredentials credentials = null;
    try {
        credentials = client.getCredentials(context);
    } catch (final RequiresHttpAction e) {
    }
    // has credentials
    if (credentials != null) {
        // get user profile
        final CasProxyProfile casProxyProfile = (CasProxyProfile) client.getUserProfile(credentials, context);
        // get proxy ticket
        final String proxyTicket = casProxyProfile.getProxyTicketFor(SERVICE_URL);
        return new ModelAndView(
                new RedirectView(CommonHelper.addParameter(SERVICE_URL, "ticket", proxyTicket)));
    } else {
        // mode proxy
    }
    return null;
}

From source file:org.openmrs.web.controller.patient.PatientListController.java

/**
 * The onSubmit function receives the form/command object that was modified by the input form
 * and saves it to the db/* w  w w . j  a  v a  2  s.c o  m*/
 * 
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 */
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
        BindException errors) throws Exception {

    HttpSession httpSession = request.getSession();

    String view = getFormView();

    if (Context.isAuthenticated()) {
        String[] patientList = request.getParameterValues("patientId");
        PatientService ps = Context.getPatientService();

        for (String o : patientList) {
            //TODO convenience method deletePatient(Integer, String) ??
            ps.voidPatient(ps.getPatient(Integer.valueOf(o)), "");
        }

        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "Patient.voided");
        view = getSuccessView();
    }

    return new ModelAndView(new RedirectView(view));
}

From source file:org.red5.webapps.admin.controllers.RegisterUserController.java

public ModelAndView onSubmit(Object command) throws ServletException {
    log.debug("onSubmit {}", command);
    UserDetails userDetails = (UserDetails) command;
    String username = userDetails.getUsername();
    String password = userDetails.getPassword();
    log.debug("User details: username={} password={}", username, password);
    try {// w  w w  .j a va  2s  .  c  om
        // register user here
        if (!((JdbcUserDetailsManager) userDetailsService).userExists(username)) {
            GrantedAuthority[] auths = new GrantedAuthority[1];
            auths[0] = new GrantedAuthorityImpl("ROLE_SUPERVISOR");
            User usr = new User(username, password, true, true, true, true, auths);
            ((JdbcUserDetailsManager) userDetailsService).createUser(usr);
            if (((JdbcUserDetailsManager) userDetailsService).userExists(username)) {
                //setup security user stuff and add them to the current "cache" and current user map   
                daoAuthenticationProvider.getUserCache().putUserInCache(usr);
            } else {
                log.warn("User registration failed for: {}", username);
            }
        } else {
            log.warn("User {} already exists", username);
        }
    } catch (Exception e) {
        log.error("Error during registration", e);
    }
    return new ModelAndView(new RedirectView(getSuccessView()));
}

From source file:org.tsm.concharto.web.spotlight.SpotlightListController.java

private ModelAndView refreshAndRedirect() {
    //refresh our round robin list
    spotlightService.refresh();/*from   ww w .  j a v a 2 s. c  om*/
    return new ModelAndView(new RedirectView(redirectView));
}

From source file:net.mindengine.oculus.frontend.web.controllers.trm.tasks.CreateSuiteController.java

@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
        BindException errors) throws Exception {
    Long taskId = Long.parseLong(request.getParameter("taskId"));
    if (taskId <= 0)
        throw new InvalidRequest();

    /*//from  ww w.  j  a v  a2s  .  co  m
     * Verifying that this task belongs to the logged user
     */
    TrmTask task = trmDAO.getTask(taskId);
    User user = getUser(request);
    if (user == null || !task.getUserId().equals(user.getId()))
        throw new NotAuthorizedException();

    TrmSuite suite = (TrmSuite) command;
    suite.setTaskId(taskId);
    Long suiteId = trmDAO.saveSuite(suite);

    return new ModelAndView(new RedirectView("../grid/edit-suite?id=" + suiteId));
}