PDA

View Full Version : Form submiting



Georgioa
24 Jun 2009, 6:51 AM
Hi

I'm in troubles with ExtDirect and foms.

I'm trying to send a little form with 2 textFields to my server. The server has to respond :
Welcome FirstParam SecondParam !

Here is my test code :


Ext.onReady(function(){
Ext.Direct.addProvider(Ext.app.REMOTING_API);

var testForm = new Ext.FormPanel({
labelWidth:80,
frame:false,
defaultType:'textfield',
paramOrder: ['lastName','firstName'],
api:{
submit:TestDirect.getWelcome
},
items:[{
id:'lastName',
fieldLabel:'Nom',
name:'lastName',
allowBlank:false
},{
id:'firstName',
fieldLabel:'Prénom',
name:'firstName',
allowBlank:false
}],
buttons:[{
text:'Welcome',
handler:function(){
testForm.getForm().submit();
}
}]
});


testForm.render(document.body);


Ext.Direct.on('exception', function(e){
alert(e.type + " : " + e.message);
console.log(e);
});
});

When i clic on my button, my POST is :

{"action":"TestDirect","method":"getWelcome","data":[{"lastName":"qtip":""},"firstName":{"qtip":""}}],"type":"rpc","tid":2}

How can i send my textfields values to the server?

I tried to do like it was explained in this post (http://extjs.com/forum/showthread.php?t=71339), but i cant get it work !

Best regards

Georgio

elishnevsky
24 Jun 2009, 7:29 AM
In your remoting API you're missing additional option for your method - formHandler:true, like so:


Ext.app.REMOTING_API = {
"url":"router_url_here",
"type":"remoting",
"actions":{
"TestDirect":[{
"name":"getWelcome",
"len":0
"formHandler":true
}]
}
};

aconran
24 Jun 2009, 6:04 PM
Georgio -

elishnevsky has provided you with the correct advice above. Also inside of your getWelcome method remember that your form fields will be POST'd and must be pulled out of the appropriate scope with whatever server-side technology you are using.

Georgioa
25 Jun 2009, 1:40 AM
Thanks for answers.

I've tested it but now my client sends 2 requests, first is a normal POST with this :


extAction :TestDirect
extMethod : getWelcome
extTID : 3
extType : rpc
extUpload : false
firstName : Test
lastName : Test2
The other POST is a JSON string :

{"action":"TestDirect","method":"getWelcome","type":"rpc","tid":3}Why do I have 2 POST? Do I miss something?

I use Java servlet with Tomcat for my server. I'm trying extdirect4j (http://extjs.com/forum/showthread.php?t=67956)