LazyQueryContainer table with button out of sync

Hi,

I am using the LazyQueryContainer add-on to have a lazy load table implementation and I encountered an issue in the following scenario:

The table has a few columns with data and 1 column with a button.
The button has a ClickListener with some code behind it.
This works fine, even if i scroll down and click the button in one of the new lines which have been loaded.
But i get an ‘out of sync’ error on my screen when I do the following actions:

  • I have 15 rows loaded at first
  • I scroll down and 15 new rows are loaded
  • I click on the button of the 15th row (or the ones before), which is one of the old ones that is still visible
    → an ‘out of sync’ error appears on my screen and i get the following warning in the console of my server:

    com.vaadin.terminal.gwt.server.AbstractCommunicationManager handleVariableBurst
    WARNING: Warning: Ignoring variable change for non-existent component, VAR_PID=PID111

I have debugged to try and figure out what went wrong but I don’t even get to my own code in the ClickListener of the button, the out of sync happens before it.

I’ve read that this warning can occur, in general, when you remove a component but it is still visible on the screen and then you try to interact with it.
I am guessing that when new lines are added to the table, the whole table is ‘refreshed’ and the old buttons ClickListeners ID’s are changed in the background?
And so the component with PID111 doesn’t exist anymore?
It’s just a guess.

Any idea’s on how to fix this in my code? Or is this a bug in LazyQueryContainer?

Thx,
Jay

What version of Vaadin do you use?

I needed lazy container in Vaadin 7 so I have tried to updated LazyQueryContainer but it didn’t work and there were some issues (I don’t remember what issues anymore… )
https://github.com/ondrej-kvasnovsky/vaadin-lazyquerycontainer

Then I have decided to build my own lazy container and it works nicely without problems (there is lazy BeanContainer at this moment). Here is the link in case you want to have a look:
https://github.com/ondrej-kvasnovsky/lazy-container

Hi Ondrej,

I’m currently using vaadin 6.7.1. I have a lot of projects so it’s not easy to go to vaadin 7 yet.
We are also using 1.2.9 of lazyQueryContainer. (tried 1.2.11 but it didn’t fix my problem)

When we switch to vaadin 7 i will certainly consider your implementation.

Thx for the reply,
Jay

HI,

I am very new to the Vaadin…i wanna use the Lazyquerycontainer because my database has a large data to load…

I saw the example of yours and on net i have implemented it but not able to run…

My classes are as follows…

public class SubEntityQueryFactory implements QueryFactory{

private EntityManager entityManager;
private QueryDefinition definition;

public SubEntityQueryFactory(EntityManager entityManager) {
super();
this.entityManager = entityManager;
}

public void setQueryDefinition(QueryDefinition definition) {
this.definition=definition;
}

public Query constructQuery(Object sortPropertyIds, boolean
sortStates) {
return new SubEntityQuery(entityManager,definition,sortPropertyIds,sortStates);
}

}

public class SubEntityQuery implements Query{
private EntityManager entityManager;
private QueryDefinition definition;
private String criteria=“”;

public SubEntityQuery(EntityManager entityManager, QueryDefinition definition,
Object sortPropertyIds, boolean
sortStates) {
super();
this.entityManager = entityManager;
this.definition = definition;

for(int i=0;i<sortPropertyIds.length;i++) {
if(i==0) {
criteria=" ORDER BY";
} else {
criteria+=“,”;
}
criteria+=" m.“+sortPropertyIds;
if(sortStates) {
criteria+=” ASC";
}
else {
criteria+=" DESC";
}
}
}

public Item constructItem() {
return new BeanItem(new SubEntity());
}

public int size() {
javax.persistence.Query query = entityManager.createNativeQuery(“SELECT count(GISubEntityID) from goinvestor…SubEntity as m”);
return ((Integer)query.getSingleResult()).intValue();

}

public List loadItems(int startIndex, int count) {
javax.persistence.Query query = entityManager.
createNativeQuery(“SELECT GISubEntityID,GIEntityID from SubEntity as m”+criteria,SubEntity.class);
query.setFirstResult(startIndex);
query.setMaxResults(count);

List subEntities = query.getResultList();
List items=new ArrayList();

for(SubEntity subEntity : subEntities) {
items.add(new BeanItem(subEntity));
}
return items;
}

public void saveItems(List addedItems, List modifiedItems,
List removedItems) {
throw new UnsupportedOperationException();
}

public boolean deleteAllItems() {
throw new UnsupportedOperationException();
}

}

@Entity
public class SubEntity implements Serializable{

/**
*
*/
private static final long serialVersionUID = 1L;
@Id
public int giSubEntityID;
public int giEntityID;

public int getgISubEntityID() {
return giSubEntityID;
}
public void setgISubEntityID(int giSubEntityID) {
this.giSubEntityID = giSubEntityID;
}
public int getgiEntityID() {
return giEntityID;
}
public void setgIEntityID(int giEntityID) {
this.giEntityID = giEntityID;
}
}

after this i am creating the lazy query container

LazyQueryContainer lqc = new LazyQueryContainer(new SubEntityQueryFactory(em),true,100);

lqc.addContainerProperty(LazyQueryView.PROPERTY_ID_ITEM_STATUS, QueryItemStatus.class,
QueryItemStatus.None, true, false);
lqc.addContainerProperty(“GISubEntityID”,Integer.class, null, true, true);
lqc.addContainerProperty(“GIEntityID”,Integer.class, null, true, true);

lqc.addContainerProperty(LazyQueryView.DEBUG_PROPERTY_ID_QUERY_INDEX, Integer.class, 0, true, false);
lqc.addContainerProperty(LazyQueryView.DEBUG_PROPERTY_ID_BATCH_INDEX, Integer.class, 0, true, false);
lqc.addContainerProperty(LazyQueryView.DEBUG_PROPERTY_ID_BATCH_QUERY_TIME, Integer.class, 0, true,
false);

and giving it to the table…

final String T_SUB_ENTITY_TABLE_COL_HEADER ={“SubEntity id”,“Entity id”};
final String T_SUB_ENTITY_TABLE_VISIBLE_COLS ={“GISubEntityID”,“GIEntityID”,};

Table filterTable = new Table();

filterTable.setSizeFull();
filterTable.setImmediate(true);
filterTable.setSelectable(true);
filterTable.setColumnCollapsingAllowed(true);
filterTable.setColumnReorderingAllowed(true);
filterTable.setContainerDataSource(buildSubEntityLazyQueryContainer());
filterTable.setVisibleColumns(T_SUB_ENTITY_TABLE_VISIBLE_COLS);
filterTable.setColumnHeaders(T_SUB_ENTITY_TABLE_COL_HEADER);

After running this program i am getting the following error

java.lang.NullPointerException
at org.vaadin.addons.lazyquerycontainer.LazyQueryContainer.getContainerProperty(LazyQueryContainer.java:186)
at com.vaadin.ui.AbstractSelect.getContainerProperty(AbstractSelect.java:753)
at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:1876)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1541)
at com.vaadin.ui.Table.attach(Table.java:3679)

Please give the proper solution i have done everything to correct it…