Example usage for org.springframework.web.servlet.mvc.support RedirectAttributes addFlashAttribute

List of usage examples for org.springframework.web.servlet.mvc.support RedirectAttributes addFlashAttribute

Introduction

In this page you can find the example usage for org.springframework.web.servlet.mvc.support RedirectAttributes addFlashAttribute.

Prototype

RedirectAttributes addFlashAttribute(String attributeName, @Nullable Object attributeValue);

Source Link

Document

Add the given flash attribute.

Usage

From source file:com.blogzhou.web.sys.user.web.controller.UserController.java

@RequestMapping(value = "changePassword")
public String changePassword(HttpServletRequest request, @RequestParam("ids") Long[] ids,
        @RequestParam("newPassword") String newPassword, @CurrentUser User opUser,
        RedirectAttributes redirectAttributes) {

    getUserService().changePassword(opUser, ids, newPassword);

    redirectAttributes.addFlashAttribute(Constants.MESSAGE, "??");

    return redirectToUrl((String) request.getAttribute(Constants.BACK_URL));
}

From source file:eionet.transfer.controller.FileOpsController.java

/**
 * Delete files by uuid./*from   www .j a  va2s . c om*/
 *
 * @param ids - list of uuids
 */
@RequestMapping(value = "/deletefiles", method = RequestMethod.POST)
public String deleteFiles(@RequestParam("id") List<String> ids, final RedirectAttributes redirectAttributes)
        throws IOException {
    uploadsService.deleteFiles(ids);
    redirectAttributes.addFlashAttribute("message", "File(s) deleted");
    return "redirect:/";
}

From source file:me.doshou.admin.maintain.dynamictask.web.controller.DynamicTaskController.java

@RequestMapping("/start")
public String startTask(@RequestParam(value = "ids", required = false) Long[] ids,
        @RequestParam(value = Constants.BACK_URL, required = false) String backURL,
        RedirectAttributes redirectAttributes) {
    if (permissionList != null) {
        this.permissionList.assertHasDeletePermission();
    }/*w  w  w .j  a  v  a 2  s.c om*/

    dynamicTaskApi.startTask(ids);

    redirectAttributes.addFlashAttribute(Constants.MESSAGE, "??");
    return redirectToUrl(backURL);
}

From source file:controller.EditBikeController.java

@RequestMapping(value = "editproduct/bike/{id}", method = POST) //de form input wordt getoets aan de Product velden, bij fouten terug naar het formulier
public String processProductEdit(@PathVariable String id, @Valid model.Car product, Errors errors,
        RedirectAttributes model) { //RedirectAttributes zijn nodig om de gebruiker ook na redirect te onthouden
    if (errors.hasErrors() || errors == null) {
        return "editBike";
    } else {//w ww.  j  a  v  a 2s .  c o m
        dao.saveProduct(product); //product updaten met formdata
        model.addFlashAttribute("product", product); //maakt tijdelijke sessie aan voor onthouden product voorbij redirect
        return "redirect:/productEditResult/bike/" + product.getId();
    }
}

From source file:com.example.securelogin.app.passwordreissue.PasswordReissueController.java

@RequestMapping(value = "create", method = RequestMethod.POST)
public String createReissueInfo(@Validated CreateReissueInfoForm form, BindingResult bindingResult, Model model,
        RedirectAttributes attributes) {
    if (bindingResult.hasErrors()) {
        return showCreateReissueInfoForm(form);
    }//  www . j  ava 2 s  .  c  om

    String rawSecret = passwordReissueService.createAndSendReissueInfo(form.getUsername());
    attributes.addFlashAttribute("secret", rawSecret);
    return "redirect:/reissue/create?complete";
}

From source file:com.logsniffer.web.controller.source.SourcesManageController.java

@RequestMapping(value = "/sources/{logSource}/delete", method = RequestMethod.POST)
@Transactional(rollbackFor = Exception.class)
String deleteSource(@PathVariable("logSource") final long logSourceId, final Model model, final Locale locale,
        final RedirectAttributes redirectAttrs) throws ResourceNotFoundException, ReferenceIntegrityException {
    final LogSource<?> source = getAndBindActiveSource(logSourceId, model);
    logsSourceProvider.deleteSource(source);
    redirectAttrs.addFlashAttribute("message", new FlashMessage(MessageType.SUCCESS,
            messageSource.getMessage("logsniffer.source.deleted", new String[] { source.getName() }, locale)));
    return "redirect:../../sources";
}

From source file:controller.EditCarController.java

@RequestMapping(value = "editproduct/car/{id}", method = POST) //de form input wordt getoets aan de Product velden, bij fouten terug naar het formulier
public String processProductEdit(@PathVariable String id, @Valid model.Car product, Errors errors,
        RedirectAttributes model) { //RedirectAttributes zijn nodig om de gebruiker ook na redirect te onthouden
    if (errors.hasErrors() || errors == null) {
        return "editCar";
    } else {//from   w  w  w  .  j a v  a 2 s .  c  o  m
        dao.saveProduct(product); //product updaten met formdata
        model.addFlashAttribute("product", product); //maakt tijdelijke sessie aan voor onthouden product voorbij redirect
        return "redirect:/productEditResult/car/" + product.getId();
    }
}

From source file:controllers.FeatureController.java

@RequestMapping("/updateAllInGroup")
public String updateAllInGroup(Map<String, Object> model,
        @RequestParam(value = "ccoId", required = false) Long ccoId,
        @RequestParam(value = "cmgId", required = false) Long cmgId, @RequestParam("guid") String guid,
        @RequestParam(value = "audial", required = false) Integer audial,
        @RequestParam(value = "visual", required = false) Integer visual,
        @RequestParam(value = "kinestet", required = false) Integer kinestet,
        @RequestParam("gparamValue") String gparamValue, @RequestParam("gpercentValue") Long gpercentValue,
        @RequestParam("gradical") String gradical, RedirectAttributes ras) throws Exception {
    featureService.updateAllInGroup(cmgId, ccoId, guid, gparamValue, gpercentValue, gradical, audial, visual,
            kinestet);/*from   ww  w .j  a  va 2  s  . co m*/
    ras.addFlashAttribute("error", featureService.getResult().getErrors());
    ras.addAttribute("ccoId", ccoId);
    ras.addAttribute("cmgId", cmgId);
    return "redirect:/Feature/showGroup";
}

From source file:eionet.transfer.controller.UserController.java

/**
 * Adds new user to database./*from  w  w w. j  a  v  a2 s .  c o  m*/
 * @param user user name
 * @param redirectAttributes
 * @return view name or redirection
 */
@RequestMapping("/add")
public String addUser(Authorisation user, RedirectAttributes redirectAttributes) {
    String userName = user.getUserId();
    if (userName.trim().equals("")) {
        redirectAttributes.addFlashAttribute("message", "User's username cannot be empty");
        return "redirect:view";
    }

    ArrayList<SimpleGrantedAuthority> grantedAuthorities = new ArrayList<SimpleGrantedAuthority>();
    if (user.getAuthorisations() != null) {
        for (String authority : user.getAuthorisations()) {
            grantedAuthorities.add(new SimpleGrantedAuthority(authority));
        }
    }
    User userDetails = new User(user.getUserId(), "", grantedAuthorities);
    if (userManagementService.userExists(userName)) {
        redirectAttributes.addFlashAttribute("message", "User " + userName + " already exists");
        return "redirect:view";
    }
    userManagementService.createUser(userDetails);
    redirectAttributes.addFlashAttribute("message",
            "User " + user.getUserId() + " added with " + rolesAsString(user.getAuthorisations()));
    return "redirect:view";
}

From source file:com.pw.ism.controllers.MainController.java

@RequestMapping(value = "/create", method = RequestMethod.POST)
public ModelAndView create(@Valid User user, BindingResult result, RedirectAttributes redirect) {
    if (result.hasErrors()) {
        return new ModelAndView("/create", "formErrors", result.getAllErrors());
    }//from  w ww .  j  ava 2 s. co m
    user.setState(false);
    System.out.println("user sso_id " + user.getSsoId());
    userRepo.save(user);
    redirect.addFlashAttribute("globalMessage", "Successfully created a new account");
    return new ModelAndView("redirect:/");
}