On 3月6日, 上午10时24分, Norris Boyd <[EMAIL PROTECTED]> wrote:
> On Mar 5, 8:31 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > On 3月5日, 下午11时36分, Norris Boyd <[EMAIL PROTECTED]> wrote:
>
> > > On Mar 4, 10:26 pm, [EMAIL PROTECTED] wrote:
>
> > > > Dear !
> > > > There are some functions whose parameter number is not predetermined
> > > > in browser? How can I implement these function in Rhino?
>
> > > > Besides, how can I define a static function?
> > > > In counter, I add the following codes to it ,
> > > > public static void jsStaticFunction_Open(Context context,
> > > > Scriptable scriptable, Object args[], Function function)
> > > > {
> > > > for(int i = 0;i<args.length;i++)
> > > > System.out.println(args[i]);
> > > > }
>
> > > > I try to visit it as counter.Open("1","2"), there are some error
> > > > messages " can't find the Open function" !
>
> > > > Thank you!
> > > > BinLi!
>
> > > Have you tried writing your classes in Java and exposing to
> > > JavaScript? It's a much simpler way to proceed and there are only a
> > > few pieces of JavaScript functionality that don't have a Java
> > > equivalent (like dynamic properties).
>
> > > --N
>
> > Dear!
> > Can you give me a simple example? Maybe you can correct my example
> > for saving time.
> > public void jsFunction_Open(Object... args)
> > {
> > for(int i = 0;i<args.length;i++)
> > System.out.println(args[i]);
> > }
>
> I don't think that variable args will work with the jsFunction_
> definition of functions.
>
> > What's more, since my project uses some static function, I want
> > to know how to define a static
> > function in java which can be exposed to javascript.
>
> Just define your java class with a static method, then you can
> reference as in the following:http://www.mozilla.org/rhino/ScriptingJava.html
>
>
>
> > Thank you very much.
>
> > BinLi
Dear Norris Boyd.
Oh, I'm so blind. The static function defintion appear in
Foo.java, but I don't notice it,
I just look the defineClass source code in ScriptableObject and find
jsStaticFunction
prefix, so I think the static function should have this prefix, but
I'm wrong.
I am very grateful for your help! Thank you a lot!
BinLi
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino