Lazy data loading with rich:dataTable and rich:dataTableScroller - jsf

I am using rich:dataTable with rich:dataTableScroller. And I don't want load all my data from DB when initialize table, because I have very many records. I want that that rich:dataTableScroller show me real page count but load page only when I switch on in. I find some solution here
But I want use rich:dataTable andrich:dataTableScroller, and don't write my own components. Have somebody some ideas ?

You should create a custom org.richfaces.model.DataProvider, and in getItemsByRange you should fetch the limited data.
You should then construct an ExtendedTableDataModel passing your custom DataProvider, and use this model in your <rich:dataTable> - value="#{myBean.myExtendedDataModel}"

You can create your own "PagedDataModel", which actually returns only the data that will be shown in the page you are seeing.
I have found an example for this here.

You can write your own datamodel as child of richfaces ExtendedDataModel, which has method:
protected List<T> loadData(int offset, int limit, List<Order> orders)

Related

Primefaces lazy loading datatable and filter form outside of table

As said in the title. Is it possible to do this?
I would like to have for instance filter form in dialog, and displayed it on demand.
I suppose it would be possible with filteredValue option, but as i understand that is not used with lazy loading.
I would appreciate any advice.

Xpages: Dynamic View Panel and DominoViewCustomizer bean

I have dynamic view panel and I am using a customizer bean to hide columns based on column names. However, I need to:
Know which view is loaded in the customizer bean
get document handle in the bean
add additional column in the bean
Why I need this: in my application I am dealing with document mappings. I want to create a column for mapped document details. as there can be different document types mapped, there can be multiple columns.
The work of seeing which view you're working with and generating the column defs (normally the same as the ones in the view, but you could add others) is done via the ViewFactory object that is returned by #getViewFactory in the customizer bean. You can see an example of overriding the method and returning a customized factory here. You can also find the source of the default one in the ExtLib here for another example. The job of the ViewFactory is to emit a ViewDef containing a series of ColumnDefs - basically, an abstract representation of the view design. That will cover 1 and 3.
Getting a handle on the document in question for number 2 is a bit more indirect. Since the customizer bean executes only during the initialization of the view, it has no direct hook to the process of rendering each row (which is where you can get the document). You can, however, set properties or content to method/value bindings that, themselves, access the document, so that they're executed per row. I do this in order to get color columns working: I create an SSJS binding for the style property that can then see the viewEntry object. If you modify that code, you could write some SSJS like #{javascript:var doc = viewEntry.getDocument(); ...other stuff here...}. If you do that, you should make sure to either always use "viewEntry" as the var name in the view or use panel.getVar() to find the variable name dynamically.

How can I implement dynamic scrolling with ajax / JSF2.2?

I have a list of items that I would like to present. I want to ajax load items as the user scrolls down (I have no problem doing this using JS). The problem that I am experiencing is that I can only re-render the whole ui:repeat and not just a component that contains new items.
Is there an common way to do this? Can I code a bean method that returns only the <li> part of the dom and handle the weaving on the client-side? Should I just write a method that returns raw data and then use JS to handle rendering?
PS .I am sure this has been asked before, but I can't find the relevant posts

Sorting in primefaces datatable not working

I use sorting in primefaces datatable and it's does not work with paginator. Where I made ​​a mistake?
<p:column headerText="Year" sortBy="#{questionnaireListBean.getQuestionnaireData(questionnaire, 'YEAR')}">
#{questionnaireListBean.getQuestionnaireData(questionnaire, 'YEAR')}
</p:column>
And view scoped bean with init data in #PostConstruct method:
public String getQuestionnaireData(Questionnaire questionnaire, String column) {
return questionnairesData.get(questionnaire).get(column);
}
So the true title of your question is : "Sorting and pagination not working together in lazy loading datatable, primefaces", that's more of a precise description of your problem.
As for the issue, it apprears that you should expect the problem. In this link, the question was "Is there any datatable JSF component than can perform lazy load pagination, and filtering and sorting on server side. If I need to implement my own solution thanks to the teams that made client side sorting and filtering, they are useless", to which the answer came "No, there isn't. Because the component library cannot know what will be the persistence mechanism.". Of course that dated from 2010...
Taking a look into Primefaces user guide 3.5, it apprears that sorting/paginator/lazy loading can cohabit, but that's more elaborte then just adding sortBy to your columns.
In fact, checking page 144 of the guide, you can see that you need to :
have a LazyDataModel object in your bean ;
Override the load method of this object ;
Bind the value of your datatable to this model.
Doing this, you might have sorting along with lazy loading. Haven't tried it, but this seems to adress your issue.
Best of luck.

jsf popupwindow with a datatable

I have a form which one of it's fields is a code and description, also a button for opening a popup window that contains a list of all of the available codes.
when the user double clickes a row from that table i want to set these values to the code and description. - how can this be done?
Another question, I want to create this popup and table to be initialized dynamically - by that i mean that if i have a few forms in my application, when ever i have a field which has a description i want to be able to open this popup and to see the available list for that field. (every field can be from a diffrent table). is it possible to create something like that? if so, how?
Any help will be appritiated,
Thank's In Advance.
Yes, it is possible. Even more, many component libraries have ready to use popup/dialog components, such as RichFaces with <rich:popupPanel> and PrimeFaces with <p:dialog>.
If you do not want to use a component library for some reason, you would need to create a custom component for this which generates basically an absolutely positioned HTML <div> element with a CSS overlay which get shown/hidden by JS on a particular click/action. The HTML/CSS/JS part should be relatively simple if you are familiar with those languages. The JSF part is somewhat hard if you have never created a custom component before, but it should be possible with a composite component as well, so you could also just create one with pure XHTML. The updating/refreshing can just take place by the usual <f:ajax> means.

Resources