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:io.getlime.push.controller.web.WebAdminController.java

@RequestMapping(value = "web/admin/app/{id}/android/upload/do.submit", method = RequestMethod.POST)
public String actionUploadAndroidCredentials(@PathVariable Long id, @Valid UploadAndroidCredentialsForm form,
        BindingResult bindingResult, RedirectAttributes attr) {
    if (bindingResult.hasErrors()) {
        attr.addFlashAttribute("fields", bindingResult);
        attr.addFlashAttribute("form", form);
        return "redirect:/web/admin/app/" + id + "/android/upload";
    }/*from  w  w w  .ja  v  a  2  s. co  m*/
    final AppCredentialsEntity appCredentialsEntity = appCredentialsRepository.findOne(id);
    appCredentialsEntity.setAndroidServerKey(form.getToken());
    appCredentialsEntity.setAndroidBundle(form.getBundle());
    appCredentialsRepository.save(appCredentialsEntity);
    return "redirect:/web/admin/app/" + id + "/edit";
}

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

@RequestMapping(value = "/table/documentation/comment/add", method = RequestMethod.POST)
public String addComment(HttpServletRequest request, RedirectAttributes redirAttr, String fqdn,
        String comment) {/*from w  w w  .  java  2 s .co  m*/
    MetascopeTable table = metascopeTableService.findByFqdn(fqdn);
    documentationService.addComment(table, comment, metascopeUserService.getUser());
    redirAttr.addFlashAttribute("comment", "created");
    return "redirect:" + request.getHeader("Referer");
}

From source file:com.gamewin.weixin.web.task.ActivationCodeController.java

@RequiresRoles(value = { "admin", "TwoAdmin", "ThreeAdmin" }, logical = Logical.OR)
@RequestMapping(value = "disabled/{id}")
public String disabled(@PathVariable("id") Long id, RedirectAttributes redirectAttributes) {
    ActivationCode activationCode = activationCodeService.getActivationCode(id);
    activationCode.setStatus("disabled");
    activationCodeService.saveActivationCode(activationCode);
    redirectAttributes.addFlashAttribute("message",
            "?'" + activationCode.getActivationCode() + "'?");
    return "redirect:/activationCode/";
}

From source file:com.github.fauu.natrank.web.controller.AdminController.java

@RequestMapping(value = "/manage-countries/merge", method = RequestMethod.POST)
public String mergeCountries(@ModelAttribute("merge") CountryTeamMerge merge,
        RedirectAttributes redirectAttributes) {
    countryService.mergeTeams(merge);//from ww w .  ja  v  a  2  s.co m

    redirectAttributes.addFlashAttribute("message", "Team merge has been completed");

    return "redirect:/admin/manage-countries";
}

From source file:io.getlime.push.controller.web.WebAdminController.java

@RequestMapping(value = "web/admin/app/{id}/ios/upload/do.submit", method = RequestMethod.POST)
public String actionUploadIosCredentials(@PathVariable Long id, @Valid UploadIosCredentialsForm form,
        BindingResult bindingResult, RedirectAttributes attr) {
    if (bindingResult.hasErrors()) {
        attr.addFlashAttribute("fields", bindingResult);
        attr.addFlashAttribute("form", form);
        return "redirect:/web/admin/app/" + id + "/ios/upload";
    }/*w  w  w  . j a  va 2 s .c  o m*/
    final AppCredentialsEntity appCredentialsEntity = appCredentialsRepository.findOne(id);
    try {
        appCredentialsEntity.setIosPrivateKey(form.getPrivateKey().getBytes());
    } catch (IOException e) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, e.getMessage(), e);
    }
    appCredentialsEntity.setIosTeamId(form.getTeamId());
    appCredentialsEntity.setIosKeyId(form.getKeyId());
    appCredentialsEntity.setIosBundle(form.getBundle());
    appCredentialsRepository.save(appCredentialsEntity);
    return "redirect:/web/admin/app/" + id + "/edit";
}

From source file:mx.edu.um.mateo.contabilidad.web.OrdenPagoController.java

@RequestMapping(value = "/elimina", method = RequestMethod.POST)
public String elimina(HttpServletRequest request, @RequestParam Long id, Model modelo,
        @ModelAttribute OrdenPago ordenPago, BindingResult bindingResult,
        RedirectAttributes redirectAttributes) {
    log.debug("Elimina ordenPago");
    try {/*from w w w . ja  v  a  2  s  . com*/
        String nombre = mgr.elimina(id);

        redirectAttributes.addFlashAttribute("message", "ordenPago.elimina.message");
        redirectAttributes.addFlashAttribute("messageAttrs", new String[] { nombre });
    } catch (Exception e) {
        log.error("No se pudo eliminar la orden de pago " + id, e);
        bindingResult.addError(
                new ObjectError("ordenPago", new String[] { "ordenPago.no.elimina.message" }, null, null));
        return Constantes.ORDENPAGO_PATH_VER + id;
    }

    return "redirect:" + Constantes.ORDENPAGO_PATH;
}

From source file:com.gamewin.weixin.web.account.UserAdminController.java

@RequiresRoles(value = { "admin", "TwoAdmin", "ThreeAdmin" }, logical = Logical.OR)
@RequestMapping(value = "disabled/{id}")
public String disabled(@PathVariable("id") Long id, RedirectAttributes redirectAttributes) {
    User user = accountService.getUser(id);
    user.setStatus("disabled");
    accountService.updateUser(user);//from ww  w.ja va 2 s. com
    redirectAttributes.addFlashAttribute("message", "" + user.getLoginName() + "?");
    return "redirect:/admin/user";
}

From source file:com.ut.healthelink.controller.adminSysHL7Controller.java

/**
 * The '/saveHL7Segment' POST request will handle submitting the new HL7 Segment
 *
 * @param HL7SegmentDetails   The object containing the HL7 Segment form fields
 * @param result   The validation result
 * @param redirectAttr   The variable that will hold values that can be read after the redirect
 *
 * @return   Will return the HL7 Customization page on "Save"
 *
 * @throws Exception/*from  ww  w. ja  va 2  s  .  c  o  m*/
 */
@RequestMapping(value = "/saveHL7Segment", method = RequestMethod.POST)
public ModelAndView saveHL7Segment(
        @ModelAttribute(value = "HL7SegmentDetails") mainHL7Segments HL7SegmentDetails,
        RedirectAttributes redirectAttr) throws Exception {

    sysAdminManager.saveHL7Segment(HL7SegmentDetails);

    redirectAttr.addFlashAttribute("savedStatus", "savedSegment");
    ModelAndView mav = new ModelAndView(new RedirectView("details?hl7Id=" + HL7SegmentDetails.gethl7Id()));
    return mav;
}

From source file:com.ut.healthelink.controller.adminSysHL7Controller.java

/**
 * The '/saveHL7Element' POST request will handle submitting the new HL7 Segment Element
 *
 * @param HL7ElementDetails   The object containing the HL7 Segment Element form fields
 * @param result   The validation result
 * @param redirectAttr   The variable that will hold values that can be read after the redirect
 *
 * @return   Will return the HL7 Customization page on "Save"
 *
 * @throws Exception//  w ww  . ja  va  2  s. c  o  m
 */
@RequestMapping(value = "/saveHL7Element", method = RequestMethod.POST)
public ModelAndView saveHL7Element(
        @ModelAttribute(value = "HL7ElementDetails") mainHL7Elements HL7ElementDetails,
        RedirectAttributes redirectAttr) throws Exception {

    sysAdminManager.saveHL7Element(HL7ElementDetails);

    redirectAttr.addFlashAttribute("savedStatus", "savedElement");
    ModelAndView mav = new ModelAndView(new RedirectView("details?hl7Id=" + HL7ElementDetails.gethl7Id()));
    return mav;
}