Announcement Announcement Module
Collapse
No announcement yet.
How to clear form fields! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    hej.

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

    Comment


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

      Comment


      • #4
        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.

        Comment


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

          Comment

          Working...
          X