| Author |
onclick row action in dataTable
|
Tim Wise
Greenhorn
Joined: Jul 25, 2009
Posts: 15
|
|
Hello everyone,
I'd like to know if there are any known solutions/patterns to enable "onclick" actions in the dataTable. My application has a list-like display for a selection of entities and a details page. Previously, before migration to JSF, I had an "onclik" action on each row in a table, like this:
<tr onclick="window.location='details.jsp?entity_id=${entity.entity_id}';"> ... </tr>
But with JSF I didn't yet find an ability to specify a JSF action for an "onclick" action in the dataTable. The only solution I've found so far is using a commandLink like this:
<h:commandLink value="View details..." actionListener="#{listController.selectEntity}"/>
It is a regression from user standpoint, because previously user could click anywhere within a row, but now he/she may click only this link which is not really convenient.
Currently I consider implementing my own "clickableDataTable" component, but I wonder if there are simpler solutions?
Thanks,
Tim
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14456
|
|
|
I'm no expert on this, but I suspect that you can do it using CSS, since there are some popular "JavaScript-free" menu systems that do so.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
Tim Wise
Greenhorn
Joined: Jul 25, 2009
Posts: 15
|
|
Hm, unfortunately I'm not an expert on CSS either. Not sure if CSS can solve this, as since what I'd like (in the ideal solution) is that an action method of a managed-bean is executed when user clicks somewhere within a table row
BTW, as of JavaScript - I'm OK with using it on a list page - is there any way to call some action method from JavaScript? Maybe it is possible to "click" on a commandButton or a commandLink from JavaScript code? Although there are questions here too:
- how to inject a JavaScript code to dataTable's rows?
- and how to find an exact button or a link?, as since there are many of them - one per row
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14456
|
|
There's nothing to support (or hinder) JavaScript in the base JSF standard. However RichFaces provides extensive JavaScript support, including the ability for JavaScript to fire off AJAX operations. You might also check their dataTable extensions - one of them might even have an "onRowClick" type of attribute you can exploit.
RichFaces isn't the only JavaScript-supportive JSF tag library, BTW. Just the one I've got the most practice with.
|
 |
Tim Wise
Greenhorn
Joined: Jul 25, 2009
Posts: 15
|
|
|
Interesting... The thing I think of, is that as since JSF 2.0b supports AJAX - is there "onclick" action available in it's dataTables?
|
 |
 |
|
|
subject: onclick row action in dataTable
|
|
|