how do I change the page size after creating the lazyquerycontainer? no way to get queryview or other classes to change this.
How does lazy query container determine how much data to pre-fetch? it seems like it has something to do with the size of the table row. The smaller the row the more data it seems to download. The larger the row the less data it prefetches.
When I have a table that shows some images via Embedded, due to the prefetching of images that are not visibile into the browser I often run into performance/usability issues.
Example. If my table contains 200 rows, my browser view is only large enough to show 10 rows, and I am on the 50th row, with page size 10, lazyquerycontainer decides to fetch records, from 25-75, though my view only shows 10 rows, it fetches 50 and tries to load all the images via Embedded into the browser creating a very sluggish experience. The scrollbar often flickers, and ui blocks, when lazyquerycontainer decides to fetch the next batch.
I am not the author, but had to read the source code for LazyQueryContainer to build an add-on on top of it.
Short answer is that the container does pretty much what it is told; therefore you probably want to look at Table to see the various parameters that control fetching/pre-fetching.
With respect to getting access to the view, a workaround is to create the lazy container with a view (there is a constructor for that), and keep a handle to the view you created.
Not sure about LQC caches but note that the Table component also has a client-side cache of rows to facilitate smoother scrolling. See Table.setCacheRate() for adjusting this.
I have implemented Query and QueryFactory Interface to implement Lazy Query Container in my project. After running the project the Query.size() function is getting called but the loaditems() is not getting called for retrieving the Recordset from Database. Please let me know if any code has to implemented to invoke loaditems().
Any Dependency for invoking loaditems() functions?
Is there any reason that LazyQueryContainer be a final class? I need to unit testing vaadin components, and if LazyQueryContainer is final i can’t mock it (at least with plain mockito).
I just started using LazyQueryContainer some days ago and I ran into the same problem as you.
Solution: you have to call LQC#addContainerProperty() at least once to trigger the loadItems(). My guess is, that LQC thinks it doesn’t need to load items because there are no columns to display.
I implemented org.vaadin.addons.lazyquerycontainer.Query and org.vaadin.addons.lazyquerycontainer.QueryFactory and use them for a LQC. While playing around with the LQC component, I saw that there are numerous calls to Query.size() that are imho unnecessary. Here is a code sample:
public final void update(String string, Integer integer)
{
lqc = new LazyQueryContainer(new TestQueryFactory(string, integer), false, 50);
query.setColumns(lqc);
table.setContainerDataSource(lqc);
table.setVisibleColumns(visCols);
}
I get
4 calls to Query.size() for each invocation of my update() routine and I get
6 calls to Query.size() for the initialisation (1 for calling table.setVisibleColumns() and 1 for each call to table.setColumnAlignment()).
I tried several variations of the code but none of them reduced the calls to Query.size().
are you sure about the
should be immutable ? I’m asking, because there are still calls to size() right before a new Query object is created. And since the amount of queried rows can vary every second, I don’t know if this could have any side effects.
i also do not agree that the size is immutable. Think of a table that increases (import running) while you ar looking at it. I think while a view to the search result is rendered no total call should be made after the initial one. Maybe a method
public SearchResult searchAndTotal(int startIndex, int count)
i am getting the following error when trying to start the sample application. googling i found it has something todo with the jpa2 specification. as i am however relatively new to jpa i do not understand how to fix that.
SCHWERWIEGEND: Servlet.service() for servlet [Lazyapp Application]
in context with path
[/LazyApp] threw exception [java.lang.NoSuchMethodError: javax.persistence.EntityManager.detach(Ljava/lang/Object;)V]
with root cause
java.lang.NoSuchMethodError: javax.persistence.EntityManager.detach(Ljava/lang/Object;)V
at org.vaadin.addons.lazyquerycontainer.EntityQuery.loadItems(EntityQuery.java:134)
at org.vaadin.addons.lazyquerycontainer.LazyQueryView.queryItem(LazyQueryView.java:246)
at org.vaadin.addons.lazyquerycontainer.LazyQueryView.getItem(LazyQueryView.java:224)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.getItem(LazyQueryContainer.java:176)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.getContainerProperty(LazyQueryContainer.java:186)
at com.vaadin.ui.AbstractSelect.getContainerProperty(AbstractSelect.java:745)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1550)
at com.vaadin.ui.Table.enableContentRefreshing(Table.java:2313)
at com.vaadin.ui.Table.setContainerDataSource(Table.java:1901)
at com.example.lazyapp.LazyappApplication.init(LazyappApplication.java:188)
I have the same problem, I have added container properties and still my custom query class loadItems() is never called.
This is what I am trying to achieve: I have a Table, to be populated by a search result. The search (in a Solr index) can be repeated with new parameters, so the Table can be reloaded with new data.
When the page is first rendered, there is no search result, so the Table is empty. When a search is started, I set the search criteria in my QueryFactory implementation and call LazyQueryContainer.refresh(). Query.size() is called (I have checked that I return a correct size), but that is all that happens.
Answering myself here… Problem solved as soon as I realized I had to trigger the load of the first batch when there is a new search. That was easy enough:
I have encountered a problem using LazyQueryContainer as data container for a ComboBox. I need to set the selected item of the ComboBox, but cannot use
Replying to myself again (this is becoming a habit…), I think I have found a/the Vaadinic way of doing this.
Problem:
I want to use a LazyQueryContainer as data container for a ComboBox with filtering
The basic filtering of the ComboBox is too slow with 10000 items in the container
Solution:
LazySearchContainer is a subclass of LazyQueryContainer which loads items from a Solr index
LazySearchContainer implements Filterable, when
addContainerFilter() adds a
SimpleStringFilter (keys pressed in ComboBox) I change the search parameters and re-query the Solr index, in removeAllContainerFilters() i reset the query to “*”
Voilà, an index-backed autocomplete, exactly what I wanted in the first place. Thanks Tommi, LazyQueryContainer made my day!
Hi everyone,
Thanks tommi for this geat addon -_-
I’ll be using the LazyQueryContainer for to load data from a remote service so i don’t have access neither for the queries nor the entityManager.i need the lazyQueryContainer to notifiy the remote service to load the next batch of data.do you have any suggestions for how should i proceed with this problem.
PS:the entityContainer needs the entityManager and a query to interact with database which i don’t have.
thank you in advance.