Announcement Announcement Module
Collapse
No announcement yet.
unable to add field errors Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • unable to add field errors

    hi,

    In my MultiActionController i need to call a service who returns a Map of errors. i need todisplay the errors on the jsp. Any ideas? i proceeded as follws and it doesnt work.

    1. implemented bind method:
    ----------------------------
    Code:
    	protected void bind(HttpServletRequest request, Object command) throws Exception {
    		ServletRequestDataBinder binder = createBinder(request, command);
    		binder.bind(request);
    		BindingResult errors = binder.getBindingResult();
    		if (command instanceof MyData) {
    			MyData data = (MyData) command;
    			data.setBinder(binder);
    			data.setErrors(errors);
    		}
    		binder.closeNoCatch();
    	}
    ----

    in my controller method:
    ------------------------
    Code:
    public ModelAndView register(HttpServletRequest request, HttpServletResponse response, MyData myData) {
          //call the service and get the map
    	BindingResult error = envoyData.getErrors();
    	for (Entry<String, String> entry : serviceErrors.entrySet()) {
    		error.rejectValue(entry.getKey(), entry.getKey(), entry.getValue());
    	}
    }
    entry.key and entry.value both correspond to valid path of the command object; The jsp just prints.. but with no errors;

    --

    When i go through the source i see almost the same is also happening there. Wondering why the field errors are not displayed.

    jsp
    ---
    Code:
    <form:input path="merchantDetails.nickName"/> </td> 
    <form:errors path="merchantDetails.nickName"  /></td> </tr>

    Any help please. I am badly stuck up. Or any alternatives>? btw we are using spring 2.5.6 version
Working...
X