Skip to content
Ralph Schaer edited this page Oct 2, 2012 · 25 revisions

Since 1.2.1 the library is able to handle FORM_POST the same way as all the other method types. FORM_POST methods in 1.1.x style are still supported. See documentation here: [Form Post Methods 1.1.x](Form Post Method1_1_x) If you use version 1.0.x of the library see documentation here: [Form Post Methods 1.0.x](Form Post Method1_0_x)
If you write 1.2.1 style FORM_POST methods exception handling described here Form Post Exception Handling is not needed.

Server

A FORM_POST method handles submits of a Ext.form.Panel. The method has to be annotated with @ExtDirectMethod(ExtDirectMethodType.FORM_POST) and it has to return an instance of (ExtDirectFormPostResult)[http://jenkins.rasc.ch/jenkins/job/ExtDirectSpring/site/apidocs/ch/ralscha/extdirectspring/bean/ExtDirectFormPostResult.html].

@Service
public class Profile {

	//...	

	@ExtDirectMethod(ExtDirectMethodType.FORM_POST)
	public ExtDirectFormPostResult updateBasicInfo(@Valid BasicInfo basicInfo, BindingResult result) {

		if (!result.hasErrors()) {
			if (basicInfo.getEmail().equals("[email protected]")) {
				result.rejectValue("email", null, "email already taken");
			}
		}

		return new ExtDirectFormPostResult(result);
	}
}

Such a method supports all the arguments a normal Spring MVC method does:
http://static.springsource.org/spring/docs/3.1.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.1.x/spring-framework-reference/html/validation.html#validation-mvc

Client

To configure a form post handler add 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
    }
  });

Examples

Clone this wiki locally