Skip to content
Ralph Schaer edited this page Apr 14, 2020 · 10 revisions

Server

Form load methods are responsible for filling values into a form. A form load method is annotated with @ExtDirectMethod(ExtDirectMethodType.FORM_LOAD) and returns an object whose property names correspond with the field names in the form.

      @ExtDirectMethod(ExtDirectMethodType.FORM_LOAD)
      public BasicInfo getBasicInfo(@RequestParam(value = "uid") long userId) {
    
        BasicInfo basicInfo = new BasicInfo();
        ...
        return basicInfo;
      }

Parameters have to be annotated with @RequestParam if the code is not compiled with debug statements on or the name differs from the request parameter name. The value attribute has to match the name of the request parameter. If there is no value attribute the name of the parameter is used. defaultValue and required attribute of the @RequestParam annotation are supported and work the same way as in Spring MVC. Server object parameters are also supported (see Simple Method).

Client

It's important that in the BasicForm configuration the paramsAsHash property is set to true. The names of the fields have to match the property names from the Java bean. The load method can be specified in the api configuration with the load property. The parameters specified in baseParams will always be sent together with the request.

    //Ext JS 3.x
    var basicInfo = new Ext.form.FormPanel( {
    //Ext JS 4.x
    var basicInfo = Ext.create('Ext.form.Panel', {
        paramsAsHash: true,
        ...    
        defaultType: 'textfield',
        items: [ {
          fieldLabel: 'Name',
          name: 'name'
        }, {
          fieldLabel: 'Email',
          name: 'email'
        }, {
          fieldLabel: 'Company',
          name: 'company'
        } ],
        baseParams: {
          uid: 5,
        },
        api: {
          load: profile.getBasicInfo,
          submit: profile.updateBasicInfo
        }
      });

It's also possible to call the load method manually and submit additional parameters. Parameters with the same name in baseParams will be overwritten.

      basicInfo.getForm().load({
        params: {
          uid: 3
        }
      });