Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need to use Java ArrayList in Javascript

 
PankajKumar jaiswal
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am working on Struts and my jsp page has an ArrayList of Objects(Privilege having PrivilegeName and PrivilegeCategory).
Now i have a dropdown of Privileges Category and whenever i select any category i have to display the names of the privileges it have. Now the problem is i dont know how to access the ArrayList into javascript and then how to iterate it so that i can get the category name and then get the list of privileges name for that category and then show it into jsp page.
Pls help.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would have to write the arraylist to the page in a way JavaScript could understand. Read this article: http://www.javaranch.com/journal/200510/Journal200510.jsp#a1

Eric
 
PankajKumar jaiswal
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't understand. Pls make it more clear.
Thanks in Advance !!
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javascript cannot access any Java objects directly.
You need to convert the list into some kind of String value (comma separated, xml, JSON etc), which you will need to convert back into a Javascript Array or object on the client (browser).
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read the article Eric linked to?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic