This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Struts and the fly likes Pass a parameter to an event handler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Pass a parameter to an event handler" Watch "Pass a parameter to an event handler" New topic
Author

Pass a parameter to an event handler

Steve Watson
Ranch Hand

Joined: Apr 08, 2003
Posts: 38
I am trying to pass a bean property value to a JavaScript function through an onclick event handler. The following code works fine (of course on click without a space) with a hard coded value of 1 passed to the function:



But how do I pass the bean parameter which I can get from:



Thanks any help.

[ January 14, 2006: Message edited by: Steve Watson ]
[ January 14, 2006: Message edited by: Steve Watson ]
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
I'm doing this off the top of my head, but something close to the following should work since a page scope attribute named with the id attribute is created by the <logic:iterate> tag:



If you wanted to make your code a little neater, you might try using the <bean:define> tag:

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Pass a parameter to an event handler