-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
marc schipperheyn opened SPR-9418 and commented
I have been playing around with RedirectAttributes and although I like the FlashAttribute function, I don't really like the way it has been implemented.
For me, FlashAttributes come into play in the GET/POST/Redirect/displayStatus chain. What I don't like is that FlashAttributes aren't a transparent part of the ModelMap but instead separated through RedirectAttributes. I would prefer to say
model.addFlashAttribute(...) in stead of having the specify RedirectAttributes separately redirectAttributes.addFlashAttribute(...).
Also, when I add a FlashAttribute to a Model/RedirectAttributes and I don't redirect, I expect the FlashAttribute to be treated as a normal model attribute. and because they are separate, it isn't.
In the flow of a Controller, whether one redirects often depends on the context. And because RedirectAttributes are separate from ModelAttributes (when they are conceptually the same), I find myself having to duplicate certain actions, which is exactly what I want to avoid.
if(!member.isActive()){
redirectAttributes.addFlashAttribute("status","Denied",RequestUtils.getLocale(request)));
model.addAttribute("status","Denied",RequestUtils.getLocale(request)));
}
if(group.isHiddenToNonMembers()){
return "empty";
}else{
return "redirect:" + URLUtils.getGroupUrl(group, request);
}
What I would expect is to have a single action against the ModelMap
model.addFlashAttribute(...)
if the controller redirects, it is treated as a flash attribute
if the controller doesn't redirect, it treated as a model attribute
No further details from SPR-9418