Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #13810

Re: JSObject.call(method, ARGS) with Safari

From Arved Sandstrom <asandstrom3minus1@eastlink.ca>
Newsgroups comp.lang.java.programmer, comp.lang.javascript
Subject Re: JSObject.call(method, ARGS) with Safari
References <jmu16i$ij2$1@speranza.aioe.org> <YOGkr.11325$DB1.340@newsfe03.iad> <jn02en$5gp$1@speranza.aioe.org> <jn0anp$l3v$1@speranza.aioe.org>
Message-ID <Pc1lr.11621$M37.265@newsfe01.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2012-04-22 21:17 -0300

Cross-posted to 2 groups.

Show all headers | View raw


On 12-04-22 04:07 AM, Richard Maher wrote:
> "Richard Maher" <maher_rj@hotspamnotmail.com> wrote in message 
> news:jn02en$5gp$1@speranza.aioe.org...
>>
>> "Daniel Pitts" <newsgroup.nospam@virtualinfinity.net> wrote in message 
>> news:YOGkr.11325$DB1.340@newsfe03.iad...
> 
>>> Not sure if this helps, but in the past I've had to do some hacky 
>>> work-arounds to work with JSObject.
>>>
>>> Check out: 
>>> <http://virtualinfinity.net/wordpress/tools/2008/10/11/javascript-and-java-applets/>
>>>
>>
>> Anyway, I'll give your code/solution a go shortly but I'm not hopeful 
>> given that I can't even get a simple appletWindow.call("topLevelFunction", 
>> args) to do other than return "null". Without arguments is not a problem.
>>
>> So in the meantime if anyone knows of an example JSObject.call("sayHello", 
>> WITHargs) that works in Safari can they please provide a pointer?
>>
>>> Daniel.
> 
> As expected, still no joy and a nullpointer. (And now IE complains that you 
> can't cast a String to JSObject)
> 
> Thanks anyway.
> 
> Anyone else done this on Safari?
>>
> Cheers Richard Maher
>>
>> PS. NO *NOT bloody EVAL* - call, Call, CALL()!
>>

I don't usually deal with Java applets of any kind, but this was
interesting. I worked up a Swing JApplet and have a JavaScript function
an a JSP page.

Since you mentioned Safari I did Safari 5.1.2 on Mac OS X 10.6.8 with
Java Plug-in 1.6.0_31.

The applet has text fields to take 2 numbers, a result text field, and a
"submit" button. The JavaScript function is

function addNums(one,two) {
  return one+two;
}

and the important 2 lines of code in the applet are

JSObject win = JSObject.getWindow(this);
Object sum = win.call("addNums", new Object[] {num1, num2});

where 'num1' and 'num2' are java.lang.Doubles. So is 'sum'.

There is not anything more to it. It worked just fine.

AHS

-- 
A fly was very close to being called a "land," cause that's what they do
half the time.
-- Mitch Hedberg

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

JSObject.call(method, ARGS) with Safari "Richard Maher" <maher_rj@hotspamnotmail.com> - 2012-04-21 18:12 +0800
  Re: JSObject.call(method, ARGS) with Safari "Richard Maher" <maher_rj@hotspamnotmail.com> - 2012-04-21 18:15 +0800
    Re: JSObject.call(method, ARGS) with Safari Lew <noone@lewscanon.com> - 2012-04-21 04:45 -0700
      Re: JSObject.call(method, ARGS) with Safari Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-04-21 09:57 -0300
        Re: JSObject.call(method, ARGS) with Safari "Richard Maher" <maher_rj@hotspamnotmail.com> - 2012-04-21 21:30 +0800
          Re: JSObject.call(method, ARGS) with Safari Lew <noone@lewscanon.com> - 2012-04-21 13:07 -0700
        Re: JSObject.call(method, ARGS) with Safari Lew <noone@lewscanon.com> - 2012-04-21 13:00 -0700
  Re: JSObject.call(method, ARGS) with Safari Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-04-21 15:48 -0700
    Re: JSObject.call(method, ARGS) with Safari "Richard Maher" <maher_rj@hotspamnotmail.com> - 2012-04-22 12:46 +0800
      Re: JSObject.call(method, ARGS) with Safari "Richard Maher" <maher_rj@hotspamnotmail.com> - 2012-04-22 15:07 +0800
        Re: JSObject.call(method, ARGS) with Safari Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-04-22 21:17 -0300
          Re: JSObject.call(method, ARGS) with Safari Richard Maher <maherrj@googlemail.com> - 2012-04-22 23:40 -0700
            Re: JSObject.call(method, ARGS) with Safari Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-04-23 20:40 -0300

csiph-web