Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Disabling a particular row in a datatable  RSS feed

 
Arun Sudharsanam
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a screen in which certain products are displayed.
If I select some products and navigate to the next page, the selected options will be displayed. If I want to add some more products I can click the add button and come to the previous page. In this Scenario the previously selected options should be preselected and disabled.

As these options are dynamic values I want to know how to disable a particular row in a datatable..
I am using <tr:table> in my application.

Any help would be appreciated..
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The word 'disable' here is ambigious. What exactly do you mean? You want do disable the input fields of the row in question, or you want to hide the row from display? If the first, just use the 'disabled' attribute. If the second, just remove it from the datamodel behind.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's common for people to directly map a persistent collection onto a JSF datatable, but that's not always a good idea. The JSF datamodel isn't supposed to be a literal model - it's supposed to be a view model.

The difference is that while you can wrap a persistent collection and make it actually be the view model, if you don't want literally what's in that collection, you need a distinct separate view model, since the view model is what determines what you see on the rendered page.

There are 2 primary times when you need this approach:

1. When you wish to filter the view (exclude certain items that are in the persistent collection). Or, more rarely, display extra rows that aren't in the persistent collection.

2. When you need to alter or augment the attributes of rows in the persistent collection. For example, to add an attribute (property) that says the row is unselectable or should be displayed in a different color or font.

The solution to case #1 is to create a new collection ("view collection") and add ONLY the items you wish displayed from the persistent collection to that new collection. The wrap the view collection. Although this can be tedious, the actual overhead is fairly small, since only references to the rows are in the view collection - the rows themselves are not copied.

The solution to case #1 is almost the same, except that you have to construct a fronting item for each displayed row that will be used to access both row data and additional properties.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!