This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes how to use javascript value in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to use javascript value in java" Watch "how to use javascript value in java" New topic
Author

how to use javascript value in java

Jason Rodrigues
Greenhorn

Joined: Oct 20, 2005
Posts: 21
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

Joined: Jan 10, 2002
Posts: 60785
    
  65

There can be no interaction between server-side Java code and client-side Javascript. Read this article to understand why.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65


<%
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

Joined: Oct 20, 2005
Posts: 21
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

Joined: Jan 10, 2002
Posts: 60785
    
  65

Are you already using Struts?

Frameset? Why on earth would you need a frameset?
Jason Rodrigues
Greenhorn

Joined: Oct 20, 2005
Posts: 21
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

Joined: Jan 10, 2002
Posts: 60785
    
  65

I still don't see what a frameset has to do with the issue of this topic.
 
jQuery in Action, 2nd edition
 
subject: how to use javascript value in java
 
Similar Threads
Dynamic values inside html:text value property
List of checkboxes and Array/ArrayList data binding not working.
Javascript error
JSP function
passing two arrays to Javascript function