Announcement Announcement Module
No announcement yet.
ModelAttribute caching? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • ModelAttribute caching?

    Hi Guys,

    I'm new to the Spring MVC side of things and I'm currently trying to learn how to develop a portlet (hosted within liferay). So far everything seems to work - but I have one snag which I'm stuck on, and would be grateful if someone could shed some light on it for me please?...

    basically, I have a portlet page which displays a "search" form - when the user completes the form and searches - I return a list of "cases" the user can select from - However, if they then go back to the search screen and change their search criteria - the new results are returned BUT so are the previous search results (this list gets added to continually)...

    My (untrained) eye is telling me that I need to reset the contents of the Model attribute to null or remove it before re-populating it with the new data - but I'm not sure what way I should do this (hence my call for help!)

    My code is below (apologies if it's badly written but I am still only learning as I go - so any improvement comments would be great also)

    package com.test.portlets.controller;
    ...imports removed to shorten code...
    @RequestMapping(value = "VIEW")
    public class CaseSearchController {
    	private CaseService caseService;
    	List<Case> caseSearchResults;
    	private Logger logger = Logger.getLogger(CaseSearchController.class);
    	public void setCaseService(CaseService caseService) {
    		this.caseService = caseService;
    	public CaseSearch getCommandObject() {"Creating Case command object");
    		return new CaseSearch();
    	@RenderMapping(params = "myaction=searchCase")
    	public String showAddCaseForm(RenderResponse response) {
    		return "caseSearch";
    	@ActionMapping(params = "myaction=searchCase")
    	public void searchCase(@ModelAttribute CaseSearch aCaseSearch,
    			BindingResult bindingResult, ActionResponse response, Model model) {
 "Inside searchCase action method");
    		if (!bindingResult.hasErrors()) {		
    			String caseStatus = aCaseSearch.getStatus();	"About to get cases with [" + "caseRef: "+ aCaseSearch.getcaseRef() + ", Status: " + caseStatus + ", Limit: 20]");
    			caseSearchResults = caseService.getCases(aCaseSearch.getcaseRef(),caseStatus , 20);			
    			model.addAttribute("caseSearchResults", caseSearchResults);			
    			response.setRenderParameter("myaction", "searchCase");			
    		} else {
    			response.setRenderParameter("myaction", "searchCase");
    		public Map<String, String> populateCaseStatusList(){
    			Map<String, String> status = new LinkedHashMap<String, String>();
    			status.put("Open", "Open");
    			status.put("Closed", "Closed");			
    			return status;	

    Any help would be great..

  • #2
    I'm having the same problem. Any news??