code-completion for Ext.Direct Methods

Get help with Spket IDE.
Post Reply
crp_spaeth
Posts: 23
Joined: Sat Jul 25, 2009 6:28 pm

code-completion for Ext.Direct Methods

Post by crp_spaeth » Wed Aug 12, 2009 8:22 am

Hi,
since I am using Ext.Direct for the comunication between the Browser and the Server it would be nice to have a the same nice codecompletion I have for my own written classes in Ext for my Direct server Methods.

For Example I have the following Direct Action imlplemented in C# on the Server:

Code: Select all

        /// <summary>
        /// Takes the Value of the Parameter Name, adds an "Echo:" and returns it
        /// </summary>
        /// <param name="name">the string wich should get returned in the way: "Echo: "+ name</param>
        /// <returns>Returns "Echo:" + the parameter</returns>
    [DirectAction]
    public class CallTypes
    {
        [DirectMethod]
        public string Echo(string name)
        {
            return "Echo: " + name;
        }
    }
This Class will get sent via my proxy-class as the following description of the function to the Client and Extjs will make the methods availble as normal Javascript functions via Ext.Direct.

Code: Select all

{ "actions" : {
      "CallTypes" : [ 
          { "formHandler" : false,
            "len" : 1,
            "name" : "Echo"
          }
      ]
    },
  "id" : "1",
  "type" : "remoting",
  
}
Since the Direct Actions are in this case written in c# there is of cause no code-completion in the spket.

Because I dont want to jump into the actual C# class to see what parameters are needed in the Direct Method I want to descripe my direct methods in a Javascript file once (I plan to automatically genareate it later ) and give it a documentation as needed in spket. Than I would like to include this file to benefit from the code-completion of spket.

For the simple Echo Function i came up with the following code:

Code: Select all

/**
 * CallTypes Class
 * @type {Object}
 */
var CallTypes = {
	/**
	 * Just a sample Remote Function.
	 * @param {Object} params
	 * @param {Function} cb the callback Function
	 * @param {Object} scope the scope to call the Callback in.
	 */
	Echo : function(params, cb, scope){
		return;

	}
}
This allows to type in "CallTypes.E" and Press ctrl+space and the it suggests Echo as I want it to be.
Realy Nice...

But....

There is on big thing missing. Since i always try to use the property paramsAsHash (Ext-Specific) the first param is not the param Name its an Object which should contain a property called name.
So whats needed here is a way to descripe the parameter type like that:

Code: Select all

/**
 * CallTypes Class
 * @type {Object}
 */
var CallTypes = {
	/**
	 * Just a sample Remote Function.
	 * @param {Object} params a Hash of Parameter
	 * @param {String} params.name the string wich should get returned in the way: "Echo: "+ name
	 * @param {Function} cb the callback Function
	 * @param {Object} scope the scope to call the Callback in.
	 */
	Echo : function(params, cb, scope){
		return;

	}
}
this should make it possiple to write "CallTypes.Echo({na" and get the code-completion for the name Property and descipes it with "the string wich should get returned in the way: "Echo: "+ name"

Is this allready possible? Is it possible to implent it? Would be very helpfull.

best regards Martin

crp_spaeth
Posts: 23
Joined: Sat Jul 25, 2009 6:28 pm

Post by crp_spaeth » Thu Aug 13, 2009 6:18 pm

No Answers or thoughts yet? come on!

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Thu Aug 13, 2009 6:48 pm

I have create a quick fix, please download file http://www.agpad.com/downloads/com.spket.js_1.6.17.jar and replace the old one.

for code

Code: Select all

CallTypes.Echo({})
make sure '}' is there, otherwise the code completion will get wrong list...

crp_spaeth
Posts: 23
Joined: Sat Jul 25, 2009 6:28 pm

Post by crp_spaeth » Thu Aug 13, 2009 9:24 pm

thanks for the reply!

But doesn't seem to work. I installed a fresh Spket Idee added your fix and just create a file with the following code

Code: Select all

/** 
 * CallTypes Class 
 * @type {Object} 
 */ 
var CallTypes = { 
   /** 
    * Just a sample Remote Function. 
    * @param {Object} p  a Hash of Parameter 
    * @param {String} p.name test
    * @param {Function} cb the callback Function 
    * @param {Object} scope the scope to call the Callback in. 
    */ 
   Echo : function(p, cb, scope){ 
      return; 

   } 
}

CallTypes.Echo({});
but the autocomplete doesnt work for nam in CallTypes.Echo({<CURSER>});
...?

crp_spaeth
Posts: 23
Joined: Sat Jul 25, 2009 6:28 pm

Post by crp_spaeth » Thu Aug 13, 2009 9:32 pm

It seems to work within the function Echo but not if you try to call the function with the parameter...

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Fri Aug 14, 2009 1:55 am

It works fine for me, what is your default JavaScript profile? you must create a custom JavaScript profile, for profile provide by plugins like "Firefox 1.5", the code completion will not work, they using different code assist engine. you can change your profile in preferences "Spket -> JavaScript Profiles"...

crp_spaeth
Posts: 23
Joined: Sat Jul 25, 2009 6:28 pm

Post by crp_spaeth » Fri Aug 14, 2009 3:57 am

Okay Since I installed a completly fresh spket IDE the default profile was still 1.5. After Adding a Extjs Profile and setting it up as default all work just fine!

Thank you very much.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests