• 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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Disabling a particular row in a datatable

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 25453
178
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
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.
 
Can you hear that? That's my theme music. I don't know where it comes from. Check under this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic