mirror of
https://github.com/ralscha/extdirectspring.git
synced 2026-10-09 09:18:19 +02:00
Page:
Form Post Method1_0_x
Pages
@JsonView
Api
Changelog
Changelog1_0_x
Changelog1_1_x
Changelog1_2_x
Changelog1_3_x
Changelog1_4_x
Changelog1_5_x
Changelog1_6_x
Config Spring Java Config
Config SpringXML
Configuration
Development
Form Load Method
Form Post Exception Handling
Form Post Method
Form Post Method1_0_x
Form Post Method1_1_x
Form Post With Upload
Form Post With Upload1_0_x
Form Post With Upload1_1_x
Home
Links
Migraton1_0_to_1_1
ModelGenerator
ModelGeneratorAPT
Polling Method
SSE Method
Setting Up Spring Java
Setup Maven
Simple Method
Simple Named Parameter Method
Store Modify Method
Store Read Method
Tree Load Method
No results
11
Form Post Method1_0_x
Ralph Schaer edited this page 2020-04-14 17:50:26 +02:00
Server
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("aaron@extjs.com")) {
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.2.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.2.x/spring-framework-reference/html/validation.html#validation-mvc
The class ExtDirectResponseBuilder helps building the mandatory response object ExtDirectResponse.
Client
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
}
});
Table of Contents
- Introduction
- Changelog 1.7.x
- Setup Maven
- Configuration
- Server Methods
- Model Generator
- Model Generator APT
- Development
- Links