Subj : RE: Help: Defining "this" as a Java object (not inheriting from ScriptableObject) To : netscape.public.mozilla.jseng From : "Fabrice DELHOSTE" Date : Thu Dec 11 2003 06:12 pm Ok. Having such a class: public class Me { public int getAge() { return age; } public void setAge(int anAge) { age = anAge; } public String getSex() { return "male"; } private int age; } My script could simply be: this.age = 33; myage = this.getAge(); So my problem is: how could I invoke a script and fix "this" to be a Java instance of my class "Me" without inheriting from ScriptableObject? I tried to register "this" as a variable but obviously, it does not work. Fabrice -----Original Message----- From: mozilla-jseng-admin@mozilla.org [mailto:mozilla-jseng-admin@mozilla.org]On Behalf Of Igor Bukanov Sent: jeudi 11 decembre 2003 17:36 To: mozilla-jseng@mozilla.org Subject: Re: Help: Defining "this" as a Java object (not inheriting from ScriptableObject) Fabrice DELHOSTE wrote: > Hi *, > > I'm a Rhino newbie (and not a Javascript fellow ;-) and I would like to have > more information on the "this" keyword and how to set it in order to invoke > properties/methods on one of my regular Java class instance. > > In fact, consider I have a Java class not inheriting from ScriptableObject > and I want -absolutely- to define "this" in the global scope as an instance > of this class. Just need to have a similar behaviour defining the "this" > variable as any other variable implemented by a Java class. How exactly do you want to script your class? Can you give a small JS fragment that you would like to use to access your class? Regards, Igor _______________________________________________ mozilla-jseng mailing list mozilla-jseng@mozilla.org http://mail.mozilla.org/listinfo/mozilla-jseng .