-
Notifications
You must be signed in to change notification settings - Fork 64
Form Post Method
The FORM_POST method handling changed in version 1.1.0. Here you find the documentation if you use FORM_POST methods with 1.0.x.
Form post methods need to fulfill some requirements:
-
These annotation are present
-
@ExtDirectMethod(ExtDirectMethodType.FORM_POST) -
@RequestMapping -
The value of the @RequestMapping method attribute is RequestMethod.POST
-
The method is a member of a Spring MVC @Controller bean
-
The method returns nothing (void) and has to write the response with the help of ExtDirectResponseBuilder.
@Controller public class Profile {
@ExtDirectMethod(ExtDirectMethodType.FORM_POST) @RequestMapping(value = "/updateBasicInfo", method = RequestMethod.POST) public void updateBasicInfo(HttpServletRequest request, HttpServletResponse response, @Valid BasicInfo basicInfo, BindingResult result) { if (!result.hasErrors()) { if (basicInfo.getEmail().equals("[email protected]")) { result.rejectValue("email", null, "email already taken"); } } ExtDirectResponseBuilder.create(request, response).addErrors(result).buildAndWrite(); }}
Such a method supports all the arguments a normal Spring MVC method does:
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-ann-requestmapping-arguments
Validation is also working the same way:
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/validation.html#validation-mvc
The class ExtDirectResponseBuilder helps building the response and writes it into the http servlet response.
See also Form Post Exception Handling
To configure a form post handler simply configure the submit property in the api configuration of BasicForm.
//Ext JS 3.x
var basicInfo = new Ext.form.FormPanel( {
//Ext JS 4.x
var basicInfo = Ext.create('Ext.form.Panel', {
...
api: {
...
submit: profile.updateBasicInfo
}
});
It's possible to send additional parameters with the submit method.
basicInfo.getForm().submit( {
params: {
foo: 'bar',
uid: 34
}
});
- Introduction
- Changelog 1.7.x
- Setup Maven
- Configuration
- Server Methods
- Model Generator
- Model Generator APT
- Development
- Links