This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to identify which commandLink was clicked? [SOLVED]

 
Leigh Taylor
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have recently jumped into the land of jsf and am trying to absorb everything there is. I have run into an issue where i have a number of commandlinks being produced within a dataTable. Each command link calls the same javaScript method. How can i parse information so the javascript method knows which link was clicked?



I have no idea who to tackle this issue. I have a hidden variable so i can access all the address matches. Though how do i know which link is clicked?

Thanks
[ February 25, 2008: Message edited by: Leigh Taylor ]
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you could set a hidden field or a variable to a unique value from each link onmousedown.

Or have each link call different javascript, that each in turn call a common javascript function.

I do not know why you are using javascript for an action method instead of server side java code, but I have not used a4j.
 
Leigh Taylor
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply Bob. As i was generating the links dynamically it wasn't possible to include individual javaScript methods.

I did however work out a solution. The problem being my limited knowledge of binding.

Simply added a binding attribute to the datatable and bound it to the backing bean.






So the link calls the java method and the method then grabs the row data which i re-injected into my JSP page on reRender.

Leigh
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!