Lazy Loading in Primefaces - jsf

I have used Primefaces DataTable and Datascrollerwith version 5.3.x. I have a requirement which should have multiple rows . the exising one is like fetching all the records(more than 100 records) at the same time. I have a idea of lazy loading with a component that supports global filter and lazy loading with collapse panel(should close the previous opened row when new row is selected) inside each row. Can someone please guide me on this , there is a ongoing issue on performance when it fetches all the records at the stretch

You have existing solution on Lazy datatable. Your service should extend LazyDataModel and implement methods on how to fetch data. Combine that with filter and you are good to go.

Related

filtering/searching on a repeat control

In my application, i would like to replace a viewpanel with a repeat control.
However, part of the functionality is there is a UI aspect that allows users to select certain fields (that correspond to the view), and only display the documents that match. The view is doing a filter that allows users to select aspects of the view to create a search (the code is under search of the view) that allows the view panel to be updated with the results of the search.
one of the things that is curious is that the viewpanel has a value of "#{javascript:view2}" vice an actual view name.
The viewpanel defines the search view and the ...
I'd like to be able to apply that same functionality to the repeat control. I don't see those attributes on the repeat control... Any pointers? Its been a while since i've worked with xpages... long enough that I've forgotten a lot already....
TIA !
Read this blog post I did a while back, it should explain what you need.
The view panel doesn't filter anything, it just displays rows from a datasource, same as a repeat control. Indeed you can add components to a ViewPanel's column, pulling from the current row by adding a var property to the dominoView datasource.
The view is bound to #{javascript:view2} (which would be better done by binding to #{view2} - there's no need to call SSJS here). view2 is a dominoView datasource somewhere on your page. The datasource is a wrapper that has properties to capture the settings for filtering and searching that you want to do. At runtime, they are calculated and changes the ViewEntries in the datasource.
Finally there's is the underlying Domino View object available also to LotusScript. This holds and will always hold all entries. The dominoView datasource queries that using the filtering and searching properties and retrieves a ViewEntryCollection or a ViewNavigator.
So whether you use a View Panel, Repeat Control, Data View or whatever else, those are just components to visually represent a collection of ViewEntries or Documents. All can be bound to a dominoView datasource. Where repeat controls and Data Views give you extra power is you can bind them to any kind of collection, not just a dominoView datasource (e.g. DocumentCollection, ViewEntryCollection, multi-value field, Java collection, etc).
I often find that doing the searches in Java and then passing the results to the repeat as a List work better and allow more options. I can get all the information I need in Java and load that into a Map or Tree. This gives me the ability to do custom sorting in the Java class and also to combine data from other views/databases easily. Since the data is now in memory it gets reloaded fast. The only thing you have to watch for is the size of the data. If you have a view with many entries (10K?) you might not want to load everything into memory...
Howard
I'm not sure if you've found a solution yet, but consider using jQuery dataTables. Oliver Busse wrote a very detailed blog post about integrating dataTables into XPages.
To get the specific formatting, I used a repeat control to include the "td", "tr" and "thead" attributes Oliver listed in his blog post.

jsf edit rows, database performance

i am new to JSF and i followed an online sample to take the edit data table as follows. May i know is this the good practice because i doubt that when the user the save the table, it will update every rows in the database thus it will causes the slow performance issue right?by the way, is JSF come with auto ajax? or it have to depend on jsf library like richfaces, primefaces and etc.
when the user the save the table, it will update every rows in the database
Instead of saving all the elements of the list, it's better to create another list with the elements that have been edited and then save the filtered list. This way you are only updating the edited elements, not all elements.
is JSF come with auto ajax?
You can add AJAX functionality to standard JSF components with the <f:ajax> tag. See http://www.jsftoolbox.com/documentation/help/12-TagReference/core/f_ajax.html.

Primefaces get all data in lazy model

I am using lazy model for datatable in Primefaces. For exporting I want to get all data, by that I mean the data that is used for counting rows.
I can get all data that is shown currently on datatable page by using:
List<Info> data = (List<Info>) lazyModel.getWrappedData();
but there may be more data on more pages. Is there any method similiar to just mentioned one to get all data from datatable?
I've tried using this, but this would always return null:
DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot()
.findComponent(":form:infoTable");
List<Info> data = dataTable.getFilteredValue();
Another way I've tried is to just make nearly the same query I am making for counting rows, with difference being that I get list of objects, not number of rows, but for that I also need a filter. If this could be a solution, how do I get a filter that I am using for lazy loading?
Generally, how could I solve this issue?
Solution is to get a filter.
I've fetched my custom filter from lazy model, and used it to query from overriden load method, so the only difference is that I did not use arguments first and page size.
Nothing really new to show in solution, I just had to get the filter:
Map<String, Object> filters = ((MyLazyDataModel) lazyModel).getFilters().getFilters();

Retrieving column values in filtered xpages view

I have a view defined on an xpage. I also have several filters (based on the columns) that the user can select and combine to filter the results in the view. I generate a query string based on this that I construct in dominoView.search (doing a complete refresh). What I would like to do is get the results of the search so that I can then update some counts displayed elsewhere on the page. I'm having a hard time figuring out where I can perform this logic, though. I'm trying to use view.getAllEntries() and then iterating over the collection. Sometimes it seems like it works, but other times I seem to be getting the unfiltered view. Someone suggested I explicitly call view.FTSearch inside one of the events (beforePageLoad?) and immediately after do my getAllEntries call, saving the results in viewScope, but I get an "Error while browses Notes view" runtime error when I try to do that. Any pointers? TIA!
EDIT: After studying the xpages lifecycle a bit (which is still a little confusing), I think I can fine-tune my question. This is my first stackoverflow question, so I hope this is okay to do and productive....
As I described, I have a dominoView defined on my xpage. A repeat iterates over the rows of the view, displaying certain fields from the documents. If I define a query in the search property, then the repeat correctly displays the reduced set of documents rather than the complete set. (The query is computed in the search property via SSJS from some variables defined in the viewScope in a combobox's eventHandler.) However, if I try to access the current entries in the view inside of the repeat's rendered section (with SSJS) using myView.getAllEntries (where myView is what's defined as the "value" of the repeat), I am still getting all of the documents, even if a query has been done. It seems like at that point, the view variable has already had its search applied (since the repeat works), so why the differing results? Is there another way to access the view's rows? To complicate this further, this is just a simple experiment that might clarify the problem; as I indicated earlier, I don't actually want to access the view data within the repeat, I want to access it in the rendered or value sections of some comboboxes defined before the repeat in the xpage file.
I hope that makes more sense now....
EDIT #2: I forgot to add that if I manually call FTSearch (or FTSearchSorted) before calling myView.getAllEntries, then I think I can make this work. It just seems unnecessary to have to do that in addition to the view's built-in search.
From what I get you want to iterate over the entries in a view that before has been filtered, i.e. whose resulting entry collection is smaller than the the view itself.
What I don't get (yet) is what you want to do with the result, or what you're axpecting to get from the iteration over your filtered view (you're mentioning some counts to be displayed somewhere else).
Probably a good way is to use the view's .getAllEntriesByKey method which returns a NotesViewEntryCollection object which then can be used for your iteration.
Don't forget to recycle the resulting NotesViewEntry objects; reason for this has been explained several times here at stackoverflow.

Server side paging for gridview in a Sharepoint webpart

I have custom some controls residing in SharepPoint webparts. I use a GridView control to take advantage of the built-in paging and column sort. The GridView gets databound from a method that iterates through an SPlist (with a foreach loop) to build a DataTable. This looping through the list is required to apply logic to process the list prior to display in the grid.
As the list get bigger, the page takes longer (forever) to load. Even though the paging permits the GridView to display only 12 rows of data, I believe the foreach loop is processing the entire list.
I've done server-side paging in .Net with both SQL and nHibernate. It should be possible to do this in SharePoint, right?. I am looking for some guidence, sample code, or any type of direction. Even a definitive "you're an idiot" would help.
Anyone done this before? Or, does anyone have an alternative databind scheam that they could suggest?
Thanks.
If its possible to get the data using an SPQuery you can use the RowLimit and ListItemCollectionPosition properties.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitemcollectionposition.aspx
http://www.zimbio.com/SQL/articles/625/Paging+SPList+Sharepoint
Paging under SharePoint is fundamentally the same as in ASP.NET and if there is a speed difference I would attribute it to your SharePoint datasource, rather than just the fact that the gridview is running in SharePoint.
Are you databinding more than you need to?
You could possibly cache your data in the Page.Cache object and destroy the cache copy whenever something like a delete or update dirties the data.

Resources