Results 1 to 8 of 8

Thread: Form submit with Direct doesn't send any data

  1. #1
    Ext JS Premium Member
    Join Date
    Dec 2010
    Posts
    20

    Default

    Have been scratching my head on this one for some time now. I am using Ext JS Direct with ColdFusion and am unable to submit a form to a submit Form Handler.

    Below is a FormPanel that gets added to a window.


    Code:
    Ext.onReady(function() {
    
        
        MyFormUi = Ext.extend(Ext.form.FormPanel, {
            width: 400,
            padding: 10,
            id: 'signupform',
            autoHeight: true,
            //paramsAsHash: true,
            api: {
                submit: Ext.ss.signup.createaccount
            },
            formId: 'regform',
            initComponent: function() {
                this.initialConfig = Ext.apply({
                    api: {submit: Ext.ss.signup.createaccount}
                }, this.initialConfig);
                this.buttons = [{
                    text: 'Submit',
                    handler: function() {
                        
                        var myform = Ext.getCmp('signupform');
                        
                        // This works
                        signupdata = myform.getForm().getFieldValues(); 
                        Ext.ss.signup.createaccount(signupdata, function() {
                            callback here...
                        });
                        
                        // This sends the requests but with no data.
                         fui.getForm().submit({
                             waitMsg: 'Saving Data...',
                            success: function(form, action){
                                Ext.MessageBox.alert('Message', 'Transaction Successful.');
                            },
                            failure: function(form, action){
                                Ext.MessageBox.alert('Message', 'Transaction Failed.');
                                
                            }
        
                        })
                   }
                }]
                this.items = [
                    {
                        xtype: 'fieldset',
                        title: 'Company Information',
                        items: [
                            {
                                xtype: 'textfield',
                                fieldLabel: 'Name',
                                anchor: '100%',
                                id: 'companyname'
                            }
                        ]
                    },
                    {
                        xtype: 'fieldset',
                        title: 'Credentials',
                        items: [
                            {
                                xtype: 'textfield',
                                fieldLabel: 'Username',
                                anchor: '100%',
                                id: 'username'
                            },
                            {
                                xtype: 'textfield',
                                fieldLabel: 'Password',
                                anchor: '100%',
                                id: 'password'
                            }
                        ]
                    }
                ];
                
    
                MyFormUi.superclass.initComponent.call(this);
            }
        });
    
        var fui = new MyFormUi(); 
        
    
    
        MyWindowUi = Ext.extend(Ext.Window, {
            title: 'Sign Up',
            autoHeight: true,
            autoWidth: true,
            initComponent: function() {
                this.items = [fui]
                MyWindowUi.superclass.initComponent.call(this);
            }
        });
        
        w = new MyWindowUi();
        w.show();
    
    });

    Extracting the form fields and sending them via
    Code:
    Ext.ss.signup.createaccount(signupdata, function() {
      callback here...
    });
    works. But submitting the form doesn't send any data. This is the Firebug console output for the post call:
    Code:
    {"action":"signup","method":"createaccount","data":[{}],"type":"rpc","tid":2}
    Any help is much appreciated.

    Kai

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    Ext.ss.signup.createaccount needs to be defined as formHandler:true.

  3. #3
    Ext JS Premium Member
    Join Date
    Dec 2010
    Posts
    20

    Default

    Condor,

    Thanks for the quick reply. Can you point me to some documentation on that? Where do I define this as true?

    Thanks,
    Kai

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    In your RemotingProvider api as a property of the method (just like 'len').

  5. #5
    Ext JS Premium Member
    Join Date
    Dec 2010
    Posts
    20

    Default

    Condor,

    Excellent. Changed my server side function accordingly. Couldn't find this in the documentation anywhere.

    Thanks for your help. Below is the solution that worked for me.

    Code:
    
    

  6. #6
    Sencha User
    Join Date
    Jul 2008
    Posts
    53

    Default

    I have a similair problem, but if I set formHandler : true I get the from "x-www-form-urlencoded" which really is odd since it should send JSON

    setting formHandler to false, sends JSON but like "above" with data : [{}] ......


    Ext.app.REMOTING_API = {"url":"/pywebos/ED",
    "type":"remoting",
    "actions":{"Albumlist": [{"name": "getAll", "len": 0},
    {"formHandler": true, "name": "add", "len": 1}]}};

    Ext.Direct.addProvider(Ext.app.REMOTING_API);

    var FP = new Ext.form.FormPanel ({
    labelWidth:75,
    id:'testForm',
    bodyStyle:'padding: 5px',
    api: {submit: Albumlist.add},
    buttons:[{text: 'Submit',
    handler: function(){FP.getForm().submit()}}],
    defaultType : 'textfield',
    items:[{fieldLabel: 'Name', name : 'name'}],
    autoWidth:true});

  7. #7
    Touch Premium Member
    Join Date
    Oct 2009
    Location
    Sydney, Australia
    Posts
    12

    Default

    Quote Originally Posted by KPradel View Post
    Have been scratching my head on this one for some time now. I am using Ext JS Direct with ColdFusion and am unable to submit a form to a submit Form Handler.

    ...

    But submitting the form doesn't send any data. This is the Firebug console output for the post call:
    Code:
    {"action":"signup","method":"createaccount","data":[{}],"type":"rpc","tid":2}
    Any help is much appreciated.

    Kai
    I doubt the fui variable is visible inside the handler
    Place the breakpoint there in Firebug and you'll see

  8. #8
    Sencha User
    Join Date
    Jul 2011
    Location
    The Netherlands
    Posts
    24

    Default How did you resolve this?

    Jash or anyone else,
    Did you manage to resolve this??? I havethe exact same problem. I want to use directSubmit.
    With fotmHandler to Flase, I get a standard http POST, with all the form fields correct. With true I get data:{[undefined]}
    I'm using asp.net MVC on serverside and I added the [formHandler] to server method. But still don't get correct Json. Panel setup is just like yours below..


    Quote Originally Posted by jash View Post
    I have a similair problem, but if I set formHandler : true I get the from "x-www-form-urlencoded" which really is odd since it should send JSON

    setting formHandler to false, sends JSON but like "above" with data : [{}] ......


    Ext.app.REMOTING_API = {"url":"/pywebos/ED",
    "type":"remoting",
    "actions":{"Albumlist": [{"name": "getAll", "len": 0},
    {"formHandler": true, "name": "add", "len": 1}]}};

    Ext.Direct.addProvider(Ext.app.REMOTING_API);

    var FP = new Ext.form.FormPanel ({
    labelWidth:75,
    id:'testForm',
    bodyStyle:'padding: 5px',
    api: {submit: Albumlist.add},
    buttons:[{text: 'Submit',
    handler: function(){FP.getForm().submit()}}],
    defaultType : 'textfield',
    items:[{fieldLabel: 'Name', name : 'name'}],
    autoWidth:true});

Similar Threads

  1. FormPanel submit action doesn't send form fields
    By errd in forum Ext 3.x: Help & Discussion
    Replies: 8
    Last Post: 6 Apr 2011, 8:08 AM
  2. form.submit doesn't call url in form submit action
    By webwolfi in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 26 Apr 2009, 10:16 AM
  3. Why form.submit() send DisplayField to POST
    By nukboon in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 20 Jul 2008, 11:44 AM
  4. Simple form submission doesn't send data
    By gwcoffey in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 11 Jul 2008, 9:20 AM
  5. Submit form with combo doesn't send valueField?
    By Confused in forum Ext 1.x: Help & Discussion
    Replies: 5
    Last Post: 17 May 2007, 6:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •