This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java array in applet

 
Joe Crew
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've created an applet that communicates with client/server java code. I now want to pass my results back to the applet. In the Java client I have an array (of strings) that I pass to the applet. However, over in the applet when I read the array I passed from the Java Client, all I get is an array that represents the first string element in the java array.
Java Client Code Snippet

/* java script function called by the Java client */

When I pop up my alert window, the printout I get is the following:
[0] = 'j'
[1] = 'o'
[2] = 'e'
and that's it. I'm thinking that this may have something to do with the fact that I am passing a string array. Has anyone worked with passing string arrays from Java to Javascript. Any assistance will be appreciated.
Joe Crew
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Joe,
According to the API the following:
public Object call(String methodName, Object args[])
Calls a JavaScript method. Equivalent to "this.methodName(args[0], args[1], ...)" in JavaScript.
which is consistent with what you are describing. I think you need to pass a single object instead of an array. You might try something like a delimited string and then change it inside your script method...
Regards,
Manfred.
 
Joe Crew
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Manfred for the advice. I too was thinking I may have to send a string back, but I really don't want to have to write a parser in javascript even though I may have to anyway. The string I would have to pass will be a nasty one. Quoted text, all number types (int, float etc), ANY character is valid, and I mean any because this will be an i18n product. Then inside a quoted string there can be nested quotes nested many times over. Don't get me wrong, I've already written this parser in Java for the Server side database because I pass it from the applet as a string in the first place. I just didn't want to write it again in js if I could just pass is as an array. Having to parse it will be slower than just passing an array and updating the DOM variables. Well I could just pass the string to the applet and in the JS call my Java parsing routine. I wonder .....
Joe Crew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic