-
1. Re: Binding List with a datatable
healeyb Jul 26, 2012 6:28 AM (in response to snjv180)I'm not sure that I'm quite with you just yet, can you provide an example of what one list would be, list1, and then list2.
Regards,
Brendan.
-
2. Re: Binding List with a datatable
snjv180 Jul 26, 2012 7:17 AM (in response to healeyb)Hello Brendan,
What I'm trying to do is I have a huge amount of data. I want to extract a sublist of this list and show this to the user. This sublist must change accordingly as we sort ascendingly or descendingly. We must be able to filter these data as well. So I just want to bind the rich datatable to the sublist that is the output. But I want the sorting and the Filtering operation to be performed within the whole list of data. This filtering and sorting operations must be done in all columns . I hope this is enough information. Thank you for the quick reply.
-
3. Re: Binding List with a datatable
healeyb Jul 26, 2012 7:51 AM (in response to snjv180)Ok, I'm not sure that the list/sublist scenario quite fits but a dataTable will display a list which can be made to include the required
information based upon user input. You don't want to be accessing the database from a getter with JSF so you'd typically have say
a List<User> allUsers in the bean and then <rich:dataTable value="#{bean.allUsers}" .../>. A commandButton/Link action method
could then rebuild the list and render= the dataTable to display refreshed information. I generally initially build the list in a
preRenderView event listener so that data is available on page load, or perhaps in a tab change listener.
The dataTable and extendedDataTable suppport lazy loading, sorting and filtering but be warned that this is fairly complex and you
want to allocate a good amount of time for this task. I don't feel that there are plentiful good examples showing this more complex
usage of the data iteration components and the best advice I can give you is to get on amazon and order a copy of Ilya's book
Practical Richfaces 2, which does contain good examples of this.
For lazy loading the value attribute of rich:dataTable references an implementation of a class which extends
org.ajax4jsf.model.ExtendedDataModel, again it's best to refer to the book to figure out how to do this.
The showcase could do with a bit more work in this area, for example if you check the filtering example in the showcase you'll
find that the xhtml and backing bean code don't quite match up (try and find allInvnetoryItems - I can't):
http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=dataTable&skin=blueSky
So you can do everything you require but don't expect to get it done in a day.
Regards,
Brendan.
-
4. Re: Binding List with a datatable
snjv180 Jul 26, 2012 10:17 AM (in response to healeyb)Thank you for the great answer.
I have the book and now I'm going to read it in full depth. I feel that datatable should be enough because I have a navigation panel that has a list like this
1>>2>>3>>4>>5. This is what I need to implement. Yes I was working on the showcase code my self but when I sorted ,the sorting was done against first a primary column and then a secondary column. Maybe some thing went wrong.
Thank you!