File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use javascript value in java

 
Jason Rodrigues
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there I have ArrayList in the sesssion
There are two tables,
The user wants to click the record on the first table and
display all the deatils in the second table .
I have a javascript function that gives me the index
but in the javascript there

The code above will generate it fine for the first object , but if i need
it to be dyanmic and pass the index i have a problem

<%
HierarcyDetail detailcv =(HierarcyDetail) (((ArrayList) (request.getSession().getAttribute("tree"))).get(index));
%>
as it doesnt undertsand index as it is a javascript variable.

Any suggestions or ideas as to how to tackle it
Thank you
-Reeve
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There can be no interaction between server-side Java code and client-side Javascript. Read this article to understand why.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

<%
HierarcyDetail detailcv =(HierarcyDetail) (((ArrayList) (request.getSession().getAttribute("tree"))).get(index));
%>
as it doesnt undertsand index as it is a javascript variable.


Naturally. The Java scriplet executes on the server long before any Javascript on the page will get a chance to execute on the client.
 
Jason Rodrigues
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankx Bear for your prompt reply . Appreciate that
I guess have to create an struts action and a frame set to handle it , was hoping i could avoid all of that
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you already using Struts?

Frameset? Why on earth would you need a frameset?
 
Jason Rodrigues
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cause the company over hear is using them as the norm , although they are planning to do away with it ... till then cant help it
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still don't see what a frameset has to do with the issue of this topic.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic