Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Returning array from applet to JavaScript

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a question for which I cannot find an answer and would be very grateful for some help.

I have a Java applet within an HTML page and I can call the applet's methods from JavaScript without a problem when the page is viewed in Internet Explorer 6.0. If an applet method returns any Java primitive data type then the value can be assigned to a JavaScript variable and displayed (and this is also true if the applet method returns a Java String). However, if an applet method returns a Java array then the JavaScript variable to which it is assigned is always valueless.

So, with Internet Explorer 6.0 is it actually possible to have an applet method that returns a Java array to JavaScript? If so, could someone please provide a simple example. Many thanks.

Terry.
 
Rancher
Posts: 4739
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Return your array as a character delimited String. Chose a delimiter that won't appear in the data. Then write a routine in Javascript to parse it and return it to an array. To speed it up, pass the number of elements as the first part of the string.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've done this kind of thing with other languages as well..

for example, passing an array as a comma delimeted string from a DLL to a VB scripting language. This idea works pretty well...
 
Terry Sessford
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you both for your suggestions. I had considered this approach but was hoping to avoid conversion to a string because one of the arrays I wish to return to JavaScript from the Applet is a byte array which I then wish to pass to an ActiveX method which will accept the byte array as a variant data type. Thus ideally I would like the JavaScript to accept the Java byte array as a sort of 'blob', the contents of which I do not not need to access in the JavaScript itself.

Terry.
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic