File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes h:commandLink selected value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "h:commandLink selected value" Watch "h:commandLink selected value" New topic

h:commandLink selected value

dmitry toryanik

Joined: Mar 07, 2012
Posts: 4

I get links in the loop. Can I get selected value on click by one of this links and pass it to popup or to a bean or to anywhere? I tried to pass the #{log.amount} value through onclick attribute, but only last value of received links is passed. Could you help me?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

Welcome to the JavaRanch, Dmitry!

This is one of the reasons why I recommend using the h:dataTable instead of ui:repeat. dataTables have a corresponding DataModel object that contains that sort of information. a4j:repeat is a lot like ui:repeat, except that it allows limiting the data submitted on the AJAX request to just the current iteration's elements.

Unfortunately, the RichFaces docs are woefully inadequate on what's what. For example, they list the "value" as being "The current value for this component." and of type java.lang.Object. I doubt it. It's almost certainly got to be an iterable object - either an array or a Collection, not just any old object.

I suspect that the "ajaxKeys" attribute is what you need, but they don't give a sensible explanation of how it works.

One reason I'm not more familiar with this particular tag is that I use the dataTable. Instead of an h:commandLink, I use the a4j:commandLink with an ajaxSingle="true" set to limit the submit to not merely the current row, but to the single element that's of interest: the link itself. In the commandLink's action method, I call the getRowData() method on the dataTable (model), which would then provide me with the information I needed as to which log file to display.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: h:commandLink selected value
jQuery in Action, 3rd edition