@SessionAttributes doesn't get removed in Spring Portlet MVC
I have a simple Portlet that I expect to take some user input, do some stuff and show a success message. The code goes like this:
Code:
@Controller(value = "myController")
@RequestMapping(value = "VIEW")
@SessionAttributes("myCommand")
public class MyController {
@ModelAttribute("someList")
public Map<String, String> getSomeList() {
return theList;
}
@ModelAttribute("myCommand")
public CambioPlanCommand getCommandObject(PortletSession session,
Principal principal) throws SeguridadMiClaroException {
MyCommand command = new MyCommand();
return command;
}
@RenderMapping
public String showView() {
return "myView";
}
@ActionMapping(params = "action=stuff")
public void doStuff(
@ModelAttribute(value = "myCommand") MyCommand datosFormulario,
BindingResult bindingResult, SessionStatus status,
PortletSession session, Principal principal, ModelMap modelMap,
PortletRequest request) {
modelMap.put("theMessage", "Stuff is done");
status.setComplete();
}
}
The first time I execute the Portlet everything goes fine: The command object gets populated, the message is put in model and my JSP shows it in screen. Then I go to another page to play with some other portlets; and when I return to my original Portlet I expect the following:
- To get an empty instance of MyCommand
- To see no Message in Screen
But I find the opossite, and I still see the message configured in the previous request. I'm very confused about this, since the Message was not configured as a SessionAttribute (only the command) and I called SessionStatus.setComplete() so if everything was stored in Session it should already be removed.
Any ideas?