File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Disable an h:dataTable element in a specific row Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Disable an h:dataTable element in a specific row" Watch "Disable an h:dataTable element in a specific row" New topic
Author

Disable an h:dataTable element in a specific row

Girish Vasmatkar
Ranch Hand

Joined: Apr 24, 2008
Posts: 199
Hi,

Is there any way I can disable an element in an h:dataTable residing in the first row ?

I have multiple rows of the datatable and each row contains a Delete button to delete that row. But I want to have that Delete button on the first row disabled all the time.

I can do this on body on load; using the generated id (raw html using view source) of the first Delete button, but the problem is the h:dataTable is set as one of the reRender properties of another element and when the data table is re-rendered, the first Delete button is enabled again.

The disabled property of the delete button, right now, simple checks for the no of rows, as shown in the code below -









Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16014
    
  20

When you want a property set on a per-row basis in a datatable, you need to provide that property at the row level, not the bean level.

For a case where you specifically want "row 0" to always be disabled, you can reference the "rowIndex" property of the table's datamodel like so:


By the way. It's not good practice to capitalize backing bean names. Capitalize classnames, lower-case instance names. JSF2's auto-naming will expect you did so.

For a more general sort of control, you'd need to add your own properties to the row class of your tablemodel. If you're fronting an ORM domain model object, that means either subclassing it to add a "deleteButtonDisabled" property or aggregating it to create a class with both the "deleteButtonDisabled" and a reference to the domail model object.


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: Disable an h:dataTable element in a specific row