PDA

View Full Version : Extjs Form submit to Spring MVC : always going to form submit failure block



sumitdangi22
1 Aug 2013, 11:33 PM
Hi Team,

I am trying to submit Extjs 4.2.1((MVC) ) form to spring mvc. I am able to submit the form and able to access the form values in spring(java). However the call back to form is always going to failure block. Could someone have a look at my code and help me what shall i send back from java so that i could get success notice in ExtJs form. Here is my code

ExtJs form submit code :

myplanform.submit({
method:'POST',
url: 'http://localhost:8080/SpringMVCPrototype/form',
reset: false,
waitTitle: "Please Wait",
waitMsg: 'Saving ...',
success: function(form, action) {
alert('form submitted..!!');
},
failure: function(form, action) {
alert('form submit failed..');
}
})

Spring MVC code to handle this submit :
@RequestMapping(value = "/form", method = RequestMethod.POST)
public @ResponseBody
ResponseEntity<String> addPlanToDB(HttpServletRequest request) {

Plan plan = new Plan();

plan.setPlanId(request.getParameter("plan_id"));
plan.setPlanName(request.getParameter("name"));
plan.setPlanDesc(request.getParameter("description"));
// processing the form ....

//sending the response back to EXTJs
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
return new ResponseEntity<String>("{success: true, requestedId:'newId'}",headers, HttpStatus.OK);

}


Everytime i submit the form ..even though the form data have been processed successfully in javacode.
I end up getting failure alert.
Thanks in advance.

existdissolve
2 Aug 2013, 10:09 AM
Can you post the actual response that you get back from the remote request? You can look in Web Developer Tools -> Network for Chrome, or Firebug console for Firefox.

sumitdangi22
5 Aug 2013, 1:18 AM
Thanks for your reply ...Its resolved now.

shooper
28 Aug 2013, 3:39 PM
The cardinal sin of forums: "Thanks, it's fixed now"

How about sharing the solution with others?

neelrath
18 Sep 2013, 4:42 AM
please provide the solution

extjs.mscit
15 Nov 2013, 6:21 AM
And how did you fix it???