Subj : Re: How to handle unknown JavaScripts functions with Rhino To : netscape.public.mozilla.jseng From : salathe@freesurf.ch (=?ISO-8859-1?Q?Dieter_Salath=E9?=) Date : Fri Sep 05 2003 09:36 am Igor Bukanov wrote in message news:<3F573C3D.1050903@fastmail.fm>... > Dieter Salathé wrote: > > Hi, > > > > in our project we have the following problem: > > we have to provide script objects, where the supported functions are > > not known at development or deploy time, like: > > > > function foo(plugin) { > > plugin.bar("Parameter1", "Parameter2", ...); > > } > > > > the 'plugin' object is a scriptable object which represents a remote > > server, which is not known when developing the Java ScriptableObjects, > > so implementing the 'jsFunction_bar' is not an possible opinion. > > > > Anybody has the same problem? Any hints are greatly appreciated. > > But how are you going to call server functions? Do you want to > effectively translate all the calls > plugin.("Parameter1", "Parameter2", ...); > into > callRemoteServer(idForPluginObjectOnserver, "", > "Parameter1", "Parameter2", ...) ? > Yes, exactly, thats what we want to do. > Or do you want on the first access to plugin properties resolve plugin > object and populate it with available name? > > In any case, you will need either to implement Scriptable interface > directly, see > http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Matrix.java for > example , or at least subclass ScriptableObject to override get and has > methods. > > Also note that since JS does not distinguish between methods and other > properties you will have to decided in your Scriptable.get method if a > particular property is callable (represents function) or not (represents > a primitive value or object). > Thank you, it works, we implemented Scriptable.get and returned the method name which must be called if the function is not known in rhino. Regards, Dieter .