GithubHelp home page GithubHelp logo

tlaukkan / vaadin-lazyquerycontainer Goto Github PK

View Code? Open in Web Editor NEW
39.0 13.0 73.0 11.85 MB

Lazy Query Container is a lazy loading container implementation for accessing data from business services.

Home Page: http://vaadin.com/directory#addon/117

Java 100.00%

vaadin-lazyquerycontainer's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vaadin-lazyquerycontainer's Issues

The issue 43 "Since version 2.0.0 in Vaadin 7.0+ Table addItem throws IndexOutOfBoundsException" still persists

Hello, when

exampleTable.addItem();

thorws IndexOutOfBoundsException

Caused by: java.lang.IndexOutOfBoundsException: Container size: 3 and item index requested: 3
at org.vaadin.addons.lazyquerycontainer.LazyQueryView.getItem(LazyQueryView.java:258)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.getItem(LazyQueryContainer.java:205)
at com.vaadin.ui.AbstractSelect.getItem(AbstractSelect.java:718)
at org.vaadin.addons.lazyquerycontainer.QueryItemStatusColumnGenerator.generateCell(QueryItemStatusColumnGenerator.java:75)
at org.vaadin.addons.lazyquerycontainer.QueryItemStatusColumnGenerator.generateCell(QueryItemStatusColumnGenerator.java:34)
at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2286)
at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2147)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1668)

JPA should have scope 'provided'

The dependency to Java Persistence API should have a scope of 'provided' because it's provided by the runtime in Java EE applications.

<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
<scope>provided</scope>

NPE in LazyQueryView

I noticed a NullPointerException which results from a corrupted cache.
I identified two causes for this:
-When trimmung the cache and modified or removed items are moved to the end of the itemCacheAccessLog, not the first entry is removed, but a random entry at position firstIndex
-When adding an item to the cache that is already contained, the old itemIndex is not removed from the itemCacheAccessLog. When later trimming the cache, at the second occurence of itemIndex the corresponding item cannot be found.

This patch should resolve the issues:
https://gist.github.com/721663

LazyQueryView performs unnecessary loads

Hello, Tommi.
I have an issue with LazyQueryView when i use LazyQueryContainer.
I use com.vaadin.ui.Table class, When i scroll my table to the (for example) 3rd page (pageLength is 25) and then execute table.refreshRowCache() (for example user want to refresh the table and there may be some changes in DB since the last fetch) Vaadin's table is trying to load records 0-65 and it calls Container.getItemIds(int startIndex, int numberOfItems).
But unfortunatelly LazyQueryContainer loads these records with paging and performs 3 queries to DB which causes to load the table very slowly (my table contains over 10 000 000 records). I think it would be great if it loads all rows together and execute the query just one time.

Thank you for your job, it is very useful for me.
Best Regards, Alex.

QueryView instance is private

private QueryView view;

Please, at least provide a protected getter and setter for this field so that extending the container will be more simple.

Remove final NestingBeanItem and final LazyNestedMethodProperty restriction

Hi,
I need to extend both mentioned classes to support further property mapping like drilldown into a map to pick up a specific value and so on. Therefore I would like to extends those classes which are declared as final. Is there a specific reason for this? If not, can you please remove this restriction?
Thanks! Sigurd

BeanQueryFactory.constructQuery should not hide exception cause

If an exception is thrown in BeanQuery constructor, cause is hidden because of way how exceptions are handled in BeanQueryFactory.constructQuery at line 83. 'throw new RuntimeException("Error instantiating query.")' should be replaced by 'throw new RuntimeException("Error instantiating query.", e)'.

no packaged source or tag for 1.2.8 ?

I am looking for the sources for version 1.2.8 (as published in the Vaadin Add-ons directory).
There does not seem to be a download, and the last tag made appears to be 1.2.7. I built a wrapper for your container and am investigating what appears to be a very subtle bug (though it could still be on my side).

Visibility of method

I need to overide method org.vaadin.addons.lazyquerycontainer.LazyQueryView.getQuery(). Maybe it should be protected.
Another thing is that when you need query object you always call getQuery() method except one time in method org.vaadin.addons.lazyquerycontainer.LazyQueryView.queryItem(int) (line: 255). Maybe it should call getQuery() too.

LazyQueryView should be extendable, or caching and debugging should be abstracted from it.

I understand the comments made on this issue, but the LazyQueryView has so much good debugging and caching functionality, that it seems a waste to have to either copy and paste the code to make your own changes, or to have to loose all those features.

The simplest solution seems to be to remove the final modifier, but in light of the aforementioned issue's comment, at the least it seems there could be an AbstractQueryView that LazyQueryView can extend, and thus make the caching and debugging functionality available to anyone who wants to implement their own QueryView.

LQC will attempt to add and then delete the same element

If you add a new element, then delete it, then commit, EntityQuery attempts to persist and then remove the same element. This is kindof silly and runs into problems in the detached case (my code is hacked to support detached instances).

Instead, it would be better to just omit "deleted new" items altogether and not attempt any JPA operations on them.

upgrade?

Any predictions for support vaadin 7.1.0?

Excessive use of size() remote call

When using the LQC, every call to size() from wherever, results in a server side call. The size() call should be cached as much as possible

Running vaadin-lazyquerycontainer-jpa-example

Hi,

I tried compiling vaadin-lazyquerycontainer-jpa-example from maven. The pom.xml did not compile. I added this repository and I got it to compile:

<repository>
   <id>vaadin-addons</id>
   <url>http://maven.vaadin.com/vaadin-addons</url>
</repository>

but this time, mvn jetty:run did not work. Do i need extra setting?

Access to added and modified items inside save event handler

I am using vaadin LQC addon feature with editable rows in my application.
I need access to addedItems and modifiedItems for validation before saving inside save event handler. Right now, i can access them inside saveItems() method but not inside save event handler.

Let me know is there a way to access them inside save event handler method.

Thanks in advance.

EntityQueryFactory should implement Serializable

Hi,

im getting the following exception.
Cannot serialize session attribute com.vaadin.terminal.gwt.server.WebApplicationContext for session c73092566274e0753f638c8e6edf
java.io.NotSerializableException: org.vaadin.addons.lazyquerycontainer.EntityQueryFactory

EntityQueryFactory has a serialVersionUID but does not implement Serializable.
This is a bug, isnt it?

Sorting nested properties does not work properly

Sorting nested properties does not work properly for me. I have a simple OneToOne relation. A person CAN have an account. When I click on the table icon of the account column the data will be sorted. When I scroll down I see the following stacktrace:

SEVERE: java.lang.RuntimeException: Unable to get item id for index: 0 from container using Container.Indexed#getIdByIndex() even though container.size() > endIndex. Returned item id was null. Check your container implementation!
at com.vaadin.data.ContainerHelpers.getItemIdsUsingGetIdByIndex(ContainerHelpers.java:90)

I think this problem occurs for that persons that have no account assigned.

I initialize the container as following:

LazyEntityContainer container = new LazyEntityContainer(manager, Person.class, 200, "id", false, true, true);
container.addContainerProperty("firstName", String.class, "", true, true);
container.addContainerProperty("account.loginName", String.class, "", true, true);

Selected item changes after a sort!

Hello!

For illustrate my purpose, go to the demo page of this excellent plugin: https://www.eelis.biz/vaadin-lazyquerycontainer/LazyQueryContainer/

  1. Select for example the second item (index = 1)
  2. Sort the index column: no problem the selected item is always the same.
  3. Sort again the same column: first item has index=99 and.... the second line with index=98 is now selected... in place of the original selected item (index = 1) who is of course not visible.

How can I solve this?

Missing release tag for 1.3.0

We are using 1.3.0 and need to fork the repository to fix issue #27 (also #36), but there seems to be no release tag.

We would probably be basing the fork on the latest released Vaadin6-compatible version (1.3.1), but need to review the changes from 1.3.0 to 1.3.1 first.

IllegalArgumentException: Removing a detached instance

EntityManager.remove() cannot be invoked on a detached instance, or you get this:

java.lang.IllegalArgumentException: Removing a detached instance Foobar#3
    at org.hibernate.ejb.event.EJB3DeleteEventListener.performDetachedEntityDeletionCheck(EJB3DeleteEventListener.java:65)
    at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:107)
    at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:73)
    at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:956)
    at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:934)
    at org.hibernate.ejb.AbstractEntityManagerImpl.remove(AbstractEntityManagerImpl.java:702)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
    at $Proxy1582.remove(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
    at $Proxy1583.remove(Unknown Source)
    at org.vaadin.addons.lazyquerycontainer.EntityQuery.saveItems(EntityQuery.java:156)

Patch to fix is attached.

Item ids do not reflect the actual item

Currently the item ids seem to be hard coded into the container, meaning that for example, firstItemId() always returns "0" and getIdByIndex always returns an integer value which is equal to the index given as parameter.

This is really problematic, since each item id should uniquely identify a specific item. The container implements the Sortable interface, so after sorting the container, the first item may not be the same as it was in the unsorted container, but yet the firstItemId() method returns "0".

This wouldn't be a problem if each item would always have the exact same position in the container, but with the Sortable interface implemented, this is not the case. Same problem applies, if I want to extend the LQC and implement the Filterable interface.

LazyQueryView and cache map

Hello,

My issue concerns the class LazyQueryVIew and propertyItemMapCache field.

The field "propertyItemMapCache" inside LazyQueryView class is declared as java.util.Map and initialized with type java.util.HashMap. The problem is that there is no simple and good solution to assign any other type (e.g. org.apache.commons.collections.map.IdentityMap) to this field. This is a really serious problem if someone uses Property class which has its own implementation of hashCode/equals. I had to face this problem because my Property class (which implements vaadin Property) must implement its own equals method and it simply doesn't work with you hashmap. Why doesn't it work? Because cache map needs to keep the references to properties for each cell. And it should keep two different references to properties even if these two properties are equal, because they may lead to different Items, for example in my world two properties are equal if they are in the same column and have the same value (e.g. column "name" in database, and properties "John" and "John" from two different rows (Items)). In such case your map replaces the Item if equal property was inside hashmap before.. and when I need to get the Item for some property I get incorrect Item (for other but equal property). So, there is a real need to have the possibility to customize your map in order to work with custom Property classes.

The simplest solution is to privide a setter for this map (something like setPropertyItemMapCache(Map<Property, Item> map)) and now i could set my own map after constructing LazyQueryView object. By the way... why LazyQueryView is final? It breaks the open-closed principle.

Finally, the only workaround now is to set the map using reflection, which is not a good practice, but it works perfectly for me when I set it to "org.apache.commons.collections.map.IdentityMap". But I'm quite annoyed doing such tricks. I think this could be done in a simpler and better way, so I would really appreciate if you fix this bug in the closest future.

Modified/deleted items are overwritten when the LazyQueryView cache size limit is exceeded

When the LazyQueryView cache size is exceeded modified and deleted items are not discarded; however if a page containing modified or deleted is reloaded those items are overwritten by the newly loaded items.
I made a simple change to LazyQueryView.java that seems to solve the issue:

299c299,304

< itemCache.put(itemIndex, item);

        // Update the item only if it's not modified or removed
        Item oldItem = itemCache.get(itemIndex);
        if (!modifiedItems.contains(oldItem) && !removedItems.contains(oldItem)) {
          itemCache.put(itemIndex, item);
        }

LazyIdList not serializable

Hi,
is there a chance to make LazyIdList serializable?
I'd monkey patch it but as LazyQueryView is final, i cannot return my own serializable Id list.

This is a problem for container that have idPropertyId set. They are not serializable then and session restoration fails.

Thanks in advance,
Michael.

LazyQueryContainer.getItem throw ClassCastException: java.lang.Long cannot be cast to java.lang.Integer

Hello,

I follow the Custom Query and QueueFactory example on the wiki page, ie Query loadItems return a list of BeanItems with my JPA object wrap inside BeanItem. The id on my JPA object is Long, not an integer.

Somehow with the lazy query container, it seems it use something like a natural number with an Integer as itemid to compare with the id from my JPA object which is a long.

I try to use this lazy query container onto a combo box like a Car object has one Driver (there could be a thousand of drivers to choose from). When the Car is in edit mode, try to select a driver from a list drivers return from lazy querycontainer and end up wtih

java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.getItem(LazyQueryContainer.java:176)
at org.vaadin.addon.customfield.beanfield.BeanFieldPropertyConverter.parse(BeanFieldPropertyConverter.java:60)
at org.vaadin.addon.customfield.ConvertingValidator.validate(ConvertingValidator.java:29)
at com.vaadin.ui.AbstractField.validate(AbstractField.java:775)
at com.vaadin.ui.AbstractField.getErrorMessage(AbstractField.java:859)
at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:783)
at com.vaadin.ui.AbstractOrderedLayout.paintContent(AbstractOrderedLayout.java:171)
at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781)
at com.vaadin.ui.AbstractOrderedLayout.paintContent(AbstractOrderedLayout.java:171)
at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781)
at com.vaadin.ui.Panel.paintContent(Panel.java:269)
at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781)

Have I chose a wrong example to follow, ie, I shouldn't follow Custom Query pattern / example?

AbstractBeanQuery should implement Serializable and remove no-arg constructor

AbstractBeanQuery doesn't implement Serializable, but does have a no-arg constructor. So upon deserializing a derived class that does implement Serializable, it will restore the fields of the derived class, and call the no-arg constructor of AbstractBeanQuery.

This results in the fields of the AbstractBeanQuery being left as null, later causing various NullPointerExceptions.

any api available to set how much to pre-fetch?

We can set the page size and lazyquerycontainer seems to automatically figure out how many table rows to fetch above and below the visible set of rows. It seems that the amount of rows that is are fetched is somewhat related to the height of each table row.

Is there a way to control this fetching behavior? if not it would be nice to be able to.

Add NestedProperties to BeanItem in AbstractBeanQuery

I need to add a NestedProperty in a BeanItem.
But the Method AbstractBeanQuery.toItem(T) is private, thus for workaraound I copied the whole class and modified toItem(T) in the copied class.

A solution for me could be to have a protected method for creation of the BeanItem, which I could override:

private Item toItem(final T bean) {
BeanItem beanItem = createBeanItem(bean);
...
}

protected BeanItem createBeanItem(T bean) {
return new BeanItem(bean);
}

performance issues when using Embedded in vaadin table

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 since the browser is trying to load images that aren't visible. This is especially issue in slower browsers like ff4 which already have rendering full screen vaadin tables.

Lazyquerycontainer should try to optimize such that images that aren't visible aren't loaded until they become visible. This kind of technique is for example used in iOS devices and other webapps.

PersistentObjectException: detached entity passed to persist

See this forum post for a question about incorrect use of persist() instead of merge().

In fact, now I'm getting this exception:

Caused by: javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: Foobar
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1214)
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1147)
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1153)
    at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:678)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
    at $Proxy718.persist(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
    at $Proxy719.persist(Unknown Source)
    at org.vaadin.addons.lazyquerycontainer.EntityQuery.saveItems(EntityQuery.java:153)
    at org.vaadin.addons.lazyquerycontainer.LazyQueryView.commit(LazyQueryView.java:410)
    at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.commit(LazyQueryContainer.java:474)
        ....
Caused by: org.hibernate.PersistentObjectException: detached entity passed to persist: Foobar
    at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:127)
    at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61)
    at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:808)
    at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:782)
    at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:786)
    at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:672)

Since version 2.0.0 in Vaadin 7.0+ Table addItem throws IndexOutOfBoundsException

Object itemId = sampleTable.addItem();

LazyQueryContainer.class

public final Object addItem() {
    final int itemIndex = queryView.addItem();
    final Object itemId = queryView.getItemIdList().get(itemIndex); <--??
    notifyItemSetChanged();
    return itemId;
}

LazyIdList.class

public T get(final int index) {
    if (index < 0 || index >= lazyQueryView.size()) {
        throw new IndexOutOfBoundsException();
    }
    final T itemId = (T) lazyQueryView.getItem(index).getItemProperty(idPropertyId).getValue();
    idIndexMap.put(itemId, index);
    return itemId;
}

public Item getItem(final int index) {
if (index < 0 || index >= size()) {
throw new IndexOutOfBoundsException("Container size: " + size() + " and item index requested: " + index); <-- THROWS
}
final int addedItemCount = addedItems.size();
if (index < addedItemCount) {
// an item from the addedItems was requested
return addedItems.get(index);
}
if (!itemCache.containsKey(index - addedItemCount)) {
// item is not in our cache, ask the query for more items
queryItem(index - addedItemCount);
} else {
// item is already in our cache
// refresh cache access log.
itemCacheAccessLog.remove(new Integer(index));
itemCacheAccessLog.addLast(new Integer(index));
}

    return itemCache.get(index - addedItemCount);
}

Caused by: com.vaadin.ui.Table$CacheUpdateException: Error during Table cache update. Additional causes not shown.
at com.vaadin.ui.Table.maybeThrowCacheUpdateExceptions(Table.java:1690)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1679)
at com.vaadin.ui.Table.refreshRowCache(Table.java:2613)
at com.vaadin.ui.Table.containerItemSetChange(Table.java:4401)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.notifyItemSetChanged(LazyQueryContainer.java:429)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.addItem(LazyQueryContainer.java:362)
at com.vaadin.ui.AbstractSelect.addItem(AbstractSelect.java:848)
at com.edicom.broker.services.manager.ui.panels.user.ApplicationsPanel$4.onDialogResult(ApplicationsPanel.java:373)
at com.edicom.broker.services.manager.ui.forms.NameDescriptionDialog.buttonClick(NameDescriptionDialog.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
... 65 more
Caused by: java.lang.IndexOutOfBoundsException: Container size: 19 and item index requested: 19
at org.vaadin.addons.lazyquerycontainer.LazyQueryView.getItem(LazyQueryView.java:258)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.getItem(LazyQueryContainer.java:205)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.getContainerProperty(LazyQueryContainer.java:217)
at com.vaadin.ui.AbstractSelect.getContainerProperty(AbstractSelect.java:788)
at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2248)
at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2147)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1668)

refresh() method does not check if value of component is still in container

Hi Tommy !

I just had some issue with LazyQueryContainer :

  • I delete some bean from the container using a business service (not using the saveBeans() method from container because in my case such a big "i do everything" method doesn't fit my requirements)
  • I refresh the container just after for displaying purpose (to remove deleted bean from table and repaint the table)

==> if I look into my table, the value (meaning the selected id : index of the deleted bean) is still there ! This causes side effects (such as NPE) because this item is not in the container anymore.

I tried to understand the value change listener mecanism while debugging but this is quite complex to me...all I can see is that some code in AbstractSelect should do the trick (fireItemSetChange() method) but it is not executed because of itemSetEventListeners being null, caused by the addListener(Container.ItemSetChangeListener listener) method being overriden in the container.

/**
 * Fires the item set change event.
 */
protected void fireItemSetChange() {
    if (itemSetEventListeners != null && !itemSetEventListeners.isEmpty()) {
        final Container.ItemSetChangeEvent event = new ItemSetChangeEvent();
        final Object[] listeners = itemSetEventListeners.toArray();
        for (int i = 0; i < listeners.length; i++) {
            ((Container.ItemSetChangeListener) listeners[i])
                    .containerItemSetChange(event);
        }
    }
    requestRepaint();
}

Anyway maybe my analysis sucks but can you tell me if it is normal behavior or a bug ?

Thanks ;)

LazyQueryContainer method getItem makes invalid call to queryView

Situation: Table is backed by LazyQueryContainer. Table has an ItemClickEvent.ItemClickListener defined. Container is changed(refreshed) and is in process of reloading. Table is clicked, this calls LazyQueryContainer.getItem passing 'null' as the itemId.

QueryView interface defines getItem as taking an int (not Integer) parameter.

This causes a NullPointerException since while null is a valid Integer, it's not a valid int.

Proposed code fix:
public final Item getItem(final Object itemId) {
return itemId == null ? null : queryView.getItem((Integer) itemId);
}

Problem in the "Or" Container Filter parsing

Hi tlaukkan !
Theres an problem in parsing "Or" Filters on version 2.0.4

When you add only two propertyes on filter, like
"addContainerFilter(new Or(...,...))", occours a IndexOfBoundsException.

Looking at your souce, i found the problem:

Line 277 of org.vaadin.addons.lazyquerycontainer.EntityQuery
"
Predicate predicate = cb.or(setFilter(filters.remove(0), cb, cq, root),
setFilter(filters.remove(1), cb, cq, root));
"
Needs to be changed to:
"
Predicate predicate = cb.or(setFilter(filters.remove(0), cb, cq, root),
setFilter(filters.remove(0), cb, cq, root));
"

Thanks by atention!

defensive programming for custom views.

The following diff is a defensive programming against situations where a custom view cannot always accurately compute a size and can sometime overshoot.

It is a simple one-word fix. Someone else already suggested the same change in the Vaadin forums. Simply use the number of items actually returned instead of the expected count.

defensive programming if a view miscomputes the size
vaadin-lazyquerycontainer/src/main/java/org/vaadin/addons/lazyquerycontainer/LazyQueryView.java
diff --git a/vaadin-lazyquerycontainer/src/main/java/org/vaadin/addons/lazyquerycontainer/LazyQueryView.java b/vaadin-lazyquerycontainer/src/main/java/org/vaadin/addons/lazyquerycontainer/LazyQueryView.java
index 227d0fc..9cd372f 100644
--- a/vaadin-lazyquerycontainer/src/main/java/org/vaadin/addons/lazyquerycontainer/LazyQueryView.java
+++ b/vaadin-lazyquerycontainer/src/main/java/org/vaadin/addons/lazyquerycontainer/LazyQueryView.java
@@ -233,7 +233,7 @@
List items = getQuery().loadItems(startIndex, count);
long queryEndTime = System.currentTimeMillis();

  •    for (int i = 0; i < count; i++) {
    
  •    for (int i = 0; i < items.size(); i++) {
         int itemIndex = startIndex + i;
         Item item = items.get(i);
    

count function in JPAQuery is expected to return Long

The size() method in the JPAQuery class expects the count function in the SQL to return a Long. On GAE with datanucleous an Integer is returned, so the cats fails. I propose to change the cast to Number, which should work in all cases.

Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
at org.vaadin.addons.lazyquerycontainer.JpaQuery.size(JpaQuery.java:121)
at org.vaadin.addons.lazyquerycontainer.LazyQueryView.size(LazyQueryView.java:129)
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.size(LazyQueryContainer.java:114)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.