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.iwethey.forums.web.user.LoginController.java

/**
 * Process a submitted form by placing the user name in the session.
 * <p>/*from  w  ww .ja  v a2s .  c  o m*/
 * @param request The servlet request object.
 * @param response The servlet response object.
 * @param command The form backing store object (a User object).
 * @param errors The Spring errors object.
 * @return The model and view.
 */
public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
        BindException errors) throws Exception {
    User user = (User) command;

    User realUser = mUserManager.getUserByNickname(user.getNickname());

    HttpSession sess = request.getSession();
    sess.setAttribute(USER_ID_ATTRIBUTE, new Integer(realUser.getId()));

    int def = realUser.getDefaultBoard();

    if (def == 0) {
        return new ModelAndView(new RedirectView(getSuccessView()));
    } else {
        return new ModelAndView(new RedirectView("../board/show.iwt?boardid=" + def));
    }
}

From source file:org.schedoscope.metascope.controller.MetascopeUserController.java

@RequestMapping(value = "/admin/user/create", method = RequestMethod.POST)
public ModelAndView createUser(HttpServletRequest request, String username, String email, String fullname,
        String password, boolean admin, String group) {
    ModelAndView mav = new ModelAndView("body/admin/user/index");

    if (email != null && !EmailValidator.getInstance().isValid(email)) {
        return mav.addObject("invalidEmail", true).addObject("service", metascopeUserService);
    }/*from ww  w  .j  a  v  a  2  s  .c o m*/

    if (metascopeUserService.userExists(username)) {
        return mav.addObject("userExists", true).addObject("service", metascopeUserService);
    } else if (metascopeUserService.emailExists(email)) {
        return mav.addObject("emailExists", true).addObject("service", metascopeUserService);
    }

    this.metascopeUserService.createUser(username, email, fullname, password, admin, group);
    return new ModelAndView(new RedirectView(request.getHeader("Referer")));
}

From source file:org.iwethey.forums.web.post.PostController.java

/**
 * Expand all history entries.//  w w w . j av a  2  s  .c om
 * <p>
 */
public ModelAndView collapseAllHistory(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    int id = RequestUtils.getRequiredIntParameter(request, "postid");
    Post post = getPostManager().getPostById(id);

    List entries = post.getEditHistory();
    if (entries != null) {
        ExpandedHistory expanded = ExpandedHistory.getExpandedHistory(request);

        for (int index = 0; index < entries.size(); index++) {
            expanded.collapse(post, index);
        }
    }

    return new ModelAndView(new RedirectView(request.getHeader("referer")));
}

From source file:org.openmrs.module.dataintegrityworkflow.web.controller.ManageIntegrityRecordsFormController.java

protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
        BindException errors) throws Exception {
    String action = request.getParameter("operation");
    int checkId = Integer.parseInt(request.getParameter("checkId"));
    String[] recordIdList = request.getParameterValues("recordId");
    DataIntegrityWorkflowService integrityWorkflowService = getDataIntegrityWorkflowService();
    IntegrityCheck integrityCheck = integrityWorkflowService.getIntegrityCheck(checkId);
    if ("assign".equals(action)) {
        String user = request.getParameter("assigneeId");
        String assignmentType = request.getParameter("assignmentOptions");
        if ("all".equals(assignmentType)) {
            int i = 0;
            recordIdList = new String[integrityCheck.getIntegrityCheckResults().size()];
            for (IntegrityCheckResult integrityCheckResult : integrityCheck.getIntegrityCheckResults()) {
                recordIdList[i] = integrityCheckResult.getIntegrityCheckResultId().toString();
                i++;// w w w .  j a  v  a 2s  .  c  o  m
            }
        }
        integrityWorkflowService.createWorkflowRecordsIfNotExists(recordIdList, checkId);
        integrityWorkflowService.assignRecords(recordIdList, checkId, user);
    }

    if ("Unassign".equals(action)) {
        String removeAssignmentType = request.getParameter("removeOptions");
        /*if("all".equals(removeAssignmentType)) {
        int i=0;
        recordIdList=new String[integrityCheck.getIntegrityCheckResults().size()];
        for(IntegrityCheckResult integrityCheckResult:integrityCheck.getIntegrityCheckResults())
        {
            recordIdList[i]=integrityCheckResult.getIntegrityCheckResultId().toString();
            i++;
        }
        }*/
        integrityWorkflowService.removeRecordsAssignees(recordIdList, checkId);
    }
    return new ModelAndView(new RedirectView(getSuccessView() + "?filter=all&checkId=" + checkId));
}

From source file:org.madsonic.controller.MultiController.java

public ModelAndView login(HttpServletRequest request, HttpServletResponse response) throws Exception {

    //        User defaultUser = securityService.getUserByName(User.USERNAME_DEFAULT);

    // Auto-login if "user" and "password" parameters are given.
    String username = request.getParameter("user");
    String password = request.getParameter("password");

    if (username != null && password != null) {

        username = StringUtil.urlEncode(username);
        password = StringUtil.urlEncode(password);

        //          password = StringUtil.urlEncode(decrypt(password));

        // LOCKOUT default user for logon
        if (username.equalsIgnoreCase("default")) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("username", "");
            map.put("password", "");
            return new ModelAndView("login", "model", map);
        }/*  w  w  w.j  ava  2  s.  co m*/

        return new ModelAndView(new RedirectView("j_spring_security_check?j_username=" + username
                + "&j_password=" + password + "&_spring_security_remember_me=checked"));
    }

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("logout", request.getParameter("logout") != null);
    map.put("error", request.getParameter("error") != null);
    map.put("brand", settingsService.getBrand());
    map.put("loginMessage", settingsService.getLoginMessage());

    User admin = securityService.getUserByName(User.USERNAME_ADMIN);

    if (admin != null) {
        if ("a40546cc4fd6a12572828bb803380888ad1bfdab".equals(admin.getPassword())) {
            map.put("insecure", true);
        }
    }
    return new ModelAndView("login", "model", map);
}

From source file:example.springdata.web.users.web.UserController.java

/**
 * Registers a new {@link User} for the data provided by the given {@link UserForm}. Note, how an interface is used to
 * bind request parameters./*from  ww  w .j av  a  2  s  . co m*/
 * 
 * @param form the request data bound to the {@link UserForm} instance.
 * @param binding the result of the binding operation.
 * @param model the Spring MVC {@link Model}.
 * @return
 */
@RequestMapping(method = RequestMethod.POST)
public Object register(UserForm userForm, BindingResult binding, Model model) {

    userForm.validate(binding, userManagement);

    if (binding.hasErrors()) {
        return "users";
    }

    userManagement.register(new Username(userForm.getUsername()), Password.raw(userForm.getPassword()));

    RedirectView redirectView = new RedirectView("redirect:/users");
    redirectView.setPropagateQueryParams(true);

    return redirectView;
}

From source file:ru.org.linux.group.GroupController.java

@RequestMapping("/group-lastmod.jsp")
public ModelAndView topicsLastmod(@RequestParam("group") int groupId,
        @RequestParam(value = "offset", required = false) Integer offsetObject) throws Exception {
    Group group = groupDao.getGroup(groupId);

    if (offsetObject != null) {
        return new ModelAndView(
                new RedirectView(group.getUrl() + "?offset=" + offsetObject.toString() + "&lastmod=true"));
    } else {/*from w ww  .  j a va 2 s.  c o  m*/
        return new ModelAndView(new RedirectView(group.getUrl() + "?lastmod=true"));
    }
}

From source file:com.qcadoo.report.internal.controller.ReportDevelopmentController.java

@RequestMapping(value = "developReport/hql", method = RequestMethod.GET)
public ModelAndView showHqlForm() {
    if (!showReportDevelopment) {
        return new ModelAndView(new RedirectView("/"));
    }/* w ww .j  a  va 2 s  .c  om*/

    return new ModelAndView(L_QCADOO_REPORT_HQL);
}

From source file:net.mindengine.oculus.frontend.web.controllers.admin.user.UserEditController.java

@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
        BindException errors) throws Exception {

    verifyPermissions(request);//  w  ww. j  a v  a2 s .c  o  m
    Long id = new Long(request.getParameter("id"));

    if (id.intValue() == 1)
        throw new Exception("Admin account cannot be changed");
    User user = (User) command;

    WebApplicationContext wac = WebApplicationContextUtils
            .getWebApplicationContext(request.getSession().getServletContext());
    List<Permission> permissions = ((PermissionList) wac.getBean("permissionList")).getPermissions();

    // Getting state of permission checkboxes

    List<Integer> newPermissionCodes = new ArrayList<Integer>();

    for (Permission p : permissions) {
        int code = p.getCode();
        String state = request.getParameter("p_" + code);
        if ("on".equals(state)) {
            newPermissionCodes.add(code);
        }
        user.getClass();
    }
    BitCrypter bitCrypter = new BitCrypter();
    String encryptedPermissions = bitCrypter.encrypt(newPermissionCodes);
    user.setPermissions(encryptedPermissions);
    if (user != null) {
        userDAO.updateUser(id, user);
    }
    return new ModelAndView(new RedirectView("../admin/edit-user?id=" + id));
}