what is 'arguments'?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

what is 'arguments'?

johnd
I'm trying to extend the rpc class to have it pass a name and pw

I can't find any docs on what the variable arguments is used for.

I am trying to override callSync so it calls the super call Sync and
adds two parameters.  Any ideas?

qx.Class.define("qxwebapp.rpc.Rpc",
{
  extend : qx.io.remote.Rpc,
  members :
  {
    uname : null,
    passwd: null,

callSync: function(methodName){
        this.debug('my sync call');
        this.debug('args: '+qx.util.Json.stringify(arguments));
        for (var i in arguments) this.debug('i: '+arguments[i]);
        this.debug('type args: '+typeof(arguments));
        arguments.callee.base.apply(this, arguments, 'john','password');

        //this.base(arguments, 'john', 'password');
   }

  }
});

------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: what is 'arguments'?

Marc Puts
Hi John,

"arguments" is feature of the javascript language.

You can use it in a function if you want to know exactly what arguments
were passed to that function. It's often used to write functions that
have dynamic parameter lists.

For example:

f = function() {
   for (var i=0;  i < arguments.length; i++) {
     alert(arguments[i]);
   }
}

f("hello", "world");  //this will show two popups


Arguments also contains some information about what function is being
called, and what function called it. Qooxdoo uses that info to implement
inheritance. That's why you always need to send it to a super function
as first parameter.

---

As for your override question: I'm not sure what you're trying to
accomplish. The callSync method of qx.io.remote.Rpc accepts only a
single parameter, so there is not point in called that function with two
added parameters.

I think you might be trying to do it backwards?! If you're trying to add
two parameters to your own callSync function, you can do something like
this:

qx.Class.define("qxwebapp.rpc.Rpc",
{
   extend : qx.io.remote.Rpc,
   members :
   {
     callSync: function(methodName) {
       this.setUsername('john');
       this.setPassword('password');
       this.base(arguments, methodName);
    }
   }
});


I hope this helps. Or maybe I didn't understand your question right?

Regards,
Marc




On 09/01/2011 08:40 PM, John de la Garza wrote:

> I'm trying to extend the rpc class to have it pass a name and pw
>
> I can't find any docs on what the variable arguments is used for.
>
> I am trying to override callSync so it calls the super call Sync and
> adds two parameters.  Any ideas?
>
> qx.Class.define("qxwebapp.rpc.Rpc",
> {
>    extend : qx.io.remote.Rpc,
>    members :
>    {
>      uname : null,
>      passwd: null,
>
> callSync: function(methodName){
>          this.debug('my sync call');
>          this.debug('args: '+qx.util.Json.stringify(arguments));
>          for (var i in arguments) this.debug('i: '+arguments[i]);
>          this.debug('type args: '+typeof(arguments));
>          arguments.callee.base.apply(this, arguments, 'john','password');
>
>          //this.base(arguments, 'john', 'password');
>     }
>
>    }
> });
>
> ------------------------------------------------------------------------------
> Special Offer -- Download ArcSight Logger for FREE!
> Finally, a world-class log management solution at an even better
> price-free! And you'll get a free "Love Thy Logs" t-shirt when you
> download Logger. Secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsisghtdev2dev
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: what is 'arguments'?

johnd
On Thu, Sep 1, 2011 at 12:13 PM, Marc Puts
<[hidden email]> wrote:
>

> I think you might be trying to do it backwards?! If you're trying to add
> two parameters to your own callSync function, you can do something like
> this:
>
> qx.Class.define("qxwebapp.rpc.Rpc",
> {
>   extend : qx.io.remote.Rpc,
>   members :
>   {
>     callSync: function(methodName) {
>       this.setUsername('john');
>       this.setPassword('password');
>       this.base(arguments, methodName);
>    }
>   }
> });
>
>

I am trying to have my function not take the args, but rather add them
to the superclass method

I want all my rpc calls to automatically have name and password pased,
so i don't have to do it on every line where I do a rpc.  Since
realizing argumetns is a javascript thing, I have been able to find
what I need.  Thanks.

>
qx.Class.define("qxwebapp.rpc.Rpc",
{
  extend : qx.io.remote.Rpc,
  members :
  {
    uname : null,
    passwd: null,
    callAsync: function(handler, methodName){
        [].push.apply(arguments,['john','password']);
        return arguments.callee.base.apply(this, arguments);
   },
    callSync: function(methodName){
        [].push.apply(arguments,['john','password']);
        return arguments.callee.base.apply(this, arguments);
   }

  }
});

------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel