-
Notifications
You must be signed in to change notification settings - Fork 64
Form Post Method1_0_x
Form post methods need to fulfill some requirements:
-
These annotation are present
-
@ExtDirectMethod(ExtDirectMethodType.FORM_POST)
-
@ResponseBody
-
@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 an instance of ExtDirectResponse
@Controller public class Profile {
@ExtDirectMethod(ExtDirectMethodType.FORM_POST) @ResponseBody @RequestMapping(value = "/updateBasicInfo", method = RequestMethod.POST) public ExtDirectResponse updateBasicInfo(Locale locale, HttpServletRequest request, @Valid BasicInfo basicInfo, BindingResult result) { if (!result.hasErrors()) { if (basicInfo.getEmail().equals("[email protected]")) { result.rejectValue("email", null, "email already taken"); } } ExtDirectResponseBuilder builder = new ExtDirectResponseBuilder(request); builder.addErrors(locale, result); return builder.build(); }}
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 mandatory response object ExtDirectResponse.
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