File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Displaying CommandLink in Datatable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Displaying CommandLink in Datatable" Watch "Displaying CommandLink in Datatable" New topic

Displaying CommandLink in Datatable

Ayan Afridi

Joined: Jan 18, 2005
Posts: 24
I want to conditionally display a h:commandLink in a dataTable row, based on a column in the DB for that row.

So for example, say the dataTable consists of three rows:

Col1, Col2, Col3
Hi, 0, NO
Hello, 1, NO
Hi, 0, YES

<h:commandLink styleClass="columnCommandLink" id="link25" action="#{dosomething}" rendered="#{var.col3IsYES}" >
<hutputText value=" [Delete]"></hutputText>

I only want the delete link to show for the third element, so the output would look like this

Col1, Col2, Col3
Hi 0 NO [update]
Hello 1 NO [update]
Hi 0 YES [update] | [delete]

I have tried the above method - it doesnt work - it will just display or not display delete for ALL rows.

Any ideas?

Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
use the "rendered" attribute of h:commandLink to show/hide the link

MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Ayan Afridi

Joined: Jan 18, 2005
Posts: 24
As I said in the post - the "rendered" column for commandLink will display or not display the link for ALL the rows in the table. It will not conditionally display the link, row by row, as I showed above. Maybe I am using it incorrectly?

I showed How I am using it above.
I agree. Here's the link:
subject: Displaying CommandLink in Datatable
It's not a secret anymore!