Results 1 to 5 of 5

Thread: How to clear form fields!

  1. #1
    Join Date
    Sep 2008
    Posts
    9

    Default How to clear form fields!

    Hello

    how to clear search fields in form after search is done.
    The corresponding search method in controller is. The result is displayed but also search fields aren't empty.

    Code:
    @RequestMapping("searchaction.html")
    	public ModelAndView searchAction(
    			@ModelAttribute("account") Account account) {
    
    		
    		List<Account> result = accountDao.findByExample(account);
    
    		Map<String, Object> modelMap = new TreeMap<String, Object>();
    		modelMap.put("result", result );
                    //this does not help
    		modelMap.put("result", new Account ());
    
    		return new ModelAndView("account_list", modelMap);
    
    	}

  2. #2
    Join Date
    Jul 2007
    Location
    Frankfurt am Main, Germany
    Posts
    15

    Default

    hej.

    what about that one?
    Code:
    ...
    		modelMap.put("result", result );
                    //this does not help
    		modelMap.put("account", new Account ());
    ....

  3. #3
    Join Date
    Sep 2008
    Posts
    9

    Default

    nop it doesn't help.
    actually i have tried this

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    If you want to clear the fields you need to reset/clear the BindingResult of the corresponding object. Just putting a new instance of the object in the model isn't going to help.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Sep 2008
    Posts
    9

    Default

    thx for response!
    how can i clear the binding result?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •