Categories

JAVA DATEBASE
Technology Network Community
Oracle Database
Fusion Middleware
Development Tools
Java
Desktop
Server & Storage Systems
Enterprise Management
Berkeley DB Family
Cloud Computing
Big Data
Business Intelligence
Architecture
Migration and Modernization
E-Business Suite
Siebel
PeopleSoft Enterprise
JD Edwards World
Industries
JD Edwards EnterpriseOne
User Productivity Kit Pro (UPK) and Tutor
Governance, Risk & Compliance (GRC)
Master Data Management (MDM)
Oracle CRM On Demand
On Demand: SaaS and Managed Applications
AutoVue Enterprise Visualization
Primavera
ATG
Agile PLM
Endeca Experience Management
Fusion Applications
Archived Forums

 



Tags

New To Java


How to pass java arraylist into javascript arrays


Hi, i have declare an arraylist  ArrayList list1 = new ArrayList();   Inside the arraylist, there are elements. Now, i wan to pass the elements in the java arraylist into javascript arrays but i encounter javascript errors. This is how i code.  var arr1 = new Array(); <% for ( int x =0; x<list1.size(); x++) { %> 	arr1[<%=x%>] = <%=(String)list1.get(x)%>;  <% } %>   how do i solve this problem?  Thanks for the guidance in advance

both the two are incompatible types.   can we pass anything from java to javascript?  Diablo

Yes, we can, from Applets to Javascript.  But the OP doesn't understand the very basics of the stuff he's working on. By the time the Javascript is executed, the JSP is long dead. JSPs and Javascript can not communicate at runtime.

Hi,  Use Quotes around string value ( arr1[indexposition] = "stringvalue", when assign to javascript array as below.  arr1[<%=x%>] = "<%=(String)list1.get(x)%>";    Regards, Ram.

JTech wrote: Hi,  Use Quotes around string value ( arr1[indexposition] = "stringvalue", when assign to javascript array as below.  arr1[<%=x%>] = "<%=(String)list1.get(x)%>";    Regards, Ram.  Hi Ram,  How about using arr1 = <%=list.toArray()%>  ??? Is this possible? I tried it but was not working on my IDE. Do you have any solutions for this??  Regards, Thiagu

raggy  Please don't post in old threads that are long dead.  When you have a question, please start a topic of your own.  Feel free to provide a link to an old thread if relevant.  I'm locking this thread now.  It's more than 6 months old.  db


Related Links

why should i choose java ?
Converting a string to hex
Can't find symbol error with registerFont() - why?
Negative garbage
example for Pagination using jsp
How to 'freeze' a JFrame during program flow
Can't run .jar --main class not found
having a few problems with the codes for this program.
Sending bytes to multiple recipients
Don't know what to check for
Arithmetic Operators Help
Cannot compile program
Copy file in different folder
Server-Client
Command Line Classpath/Import Question
java bean and its associated factory