*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "h:commandLink selected value" Watch "h:commandLink selected value" New topic
Author

h:commandLink selected value

dmitry toryanik
Greenhorn

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: 15629
    
  15

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: h:commandLink selected value
 
Similar Threads
StateVar in a4j:repeat
Printing the dynamic menu item selected in an alert
f:param at "rendered processing" time
how to pass values in onclick method of <h:commandLink>
dataTable with dynamic number of rows and columns