File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I Iterate through an Arraylist inside a javascript funtion?

 
Anoobkumar Padmanabhan
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers

In my application, i want to iterate through an Arraylist at onClick event of a button. Can i do the iteration inside a javascript function??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no ArrayList in JavaScript. That's a Java construct.
 
Anoobkumar Padmanabhan
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,

i want to iterate through an arraylist. Can i call a java method from the javascript, so that the iteration can done inside the method?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java runs on the server, JavaScript runs on the client.

If you want to call some Java code, you would have to post back a page through a normal postback OR an Ajax call. OR you have to turn the ArrayList on the server into some sort of JavaScript code when the page first is rendered.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read through this article to understand why this can never be.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic