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