• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Disable an h:dataTable element in a specific row

Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 -

Saloon Keeper
Posts: 27852
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
    Bookmark Topic Watch Topic
  • New Topic