aspose file tools*
The moose likes Struts and the fly likes How to passs an attribute of the form to the java script. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to passs an attribute of the form to the java script." Watch "How to passs an attribute of the form to the java script." New topic
Author

How to passs an attribute of the form to the java script.

Akshay Singhvi
Ranch Hand

Joined: Nov 08, 2005
Posts: 93
Hello Ranchers,
I'm struck in a situation. I am fetching a list of bean. One of the attribute of the bean i am displaying as hyperlink. On href of that i have written a javascript function. now i want to pass an unique identifier of that bean to the javascript function. How can i pass that.
see why i am doing this is because in our application we don't want query Strings to be shown when the user put the mouse on the hyper link.Is there a way out to the above problem or to the second problem.


Regards,<br />Akshay Singhvi<br />SCJP 1.4 (95%)<br />SCWCD 1.4 (86%)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Just include either an EL expression or a scriptlet for the bean attribute in your JavaScript code. Example:

<a href="javascript:void(0)" onklick="myFunction('${myBean.myAttribute}')">click here</a>

The above assumes you are running a Servlet 2.4 application that supports EL expressions. If you aren't, you must embed the EL expression in a <cut> tag or use a scriptlet.


Merrill
Consultant, Sima Solutions
Arulanand Dayalan
Ranch Hand

Joined: Aug 10, 2005
Posts: 124
If you are using Struts uou can try this way also.



Hope this helps.

Thanks and Regards,
Arul.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to passs an attribute of the form to the java script.