A beforeSelect method method in SelectionListener for Grid

I am enabling selection mode MULTI in a Grid for performing a certain operation. The thing is that, in certain situations, this grid can have a hughe amount of rows, and when one clicks on the “select all” checkbox in the corresponding column, my app gets stuck (actually it hangs) while performing the operation.

My immediate workaround was to perform a check when the checkbox is being checked (sorry for the redundancy), in order to alert the user and cancel the operation if the number of grid rows is above the critical one. My approach was to test this in the select() method of SelectionListener, but I’ve found that this fires AFTER the selection has been actually performed, thus not avoiding the problem of getting stuck.

There should be a beforeSelect() method in the interface, or any other solution I cannot think of.

Any suggestions?

Interestingly, I just discovered about setSelectionLimit() and its default value of 1000, and when my app gets hanged the UI is kept alive enought to be able to scroll through the grid and I see the defined amount of rows is indeed selected, but it still hangs even if a set the limit to, say, 200.

This grid has a size of more than 50,000 elements. It takes some time to load, and with certain operations the progression blue bar tends to get running forever, but in gener I managed it to get working. But not in this case.

Getting messier and messier.

Tried to manually scroll my grid down to circa row 200 and then, in MULTI mode, selecting the rows by clicking and dragging with the mouse from that position to top.

After a few selections were made, then I got this “Uncaught client side exception” I’ve never seen before.

Any ideas??
39704.png

More info:

This is the last message I see in the debugger before getting hanged:

{  
   "csrfToken":"bade561d-080a-4f1a-b81e-3254f3678db8",
   "rpc":[  
      [  
         "250",
         "com.vaadin.shared.ui.grid.selection.MultiSelectionModelServerRpc",
         "selectAll",
         [  

         ]
      ]
   ],
   "syncId":128,
   "clientId":118
}

In Chrome Developer Tools → Network → XHR, I see a ?v-uiId=0 to http://localhost/HEARTBEAT which gets stuck without a response after a previous successful one.

I don’t see anything unusual on these.

It sounds to me that you end up in an endless loop which calls itself. I guess when you end in the hang loop, you could press pause in your IDE, if you run the server from the IDE, and see what the stack trace is at that moment. Alternatively I think you could place a Thread.dumpStack() in the code producing the loop. Probably within a Grid selection listener. Then when it starts to spit out endless stacktraces you kill the server and look at the last output to see if there is some cycle going on.

Another thing worth looking into is to remove all listeners that you have attached to your grid and see if it does not hang after that. If it works without the listeners, you start adding them back one by one to find the one that breaks. When it breaks again, you know which listener to look into more closely.

If you really want to look into what that client side exception is all about, you need to pretty compile the widgetset to get the actual class and method names in it. I however think that the problem is server side and the client side error is just a symptom. If you want to do it, you need to modify your pom.xml:

<plugin>
  <groupId>com.vaadin</groupId>
  <artifactId>vaadin-maven-plugin</artifactId>
  ...
  <configuration>
    ...
    <style>PRETTY</style>  <-- this is what needs to be added
    ..

Then recompile widgetset for example with a "
mvn clean package
"

Thanks a lot for helping, Jens. Well, I haven’t been able to find the supposed bug yet neither have put your tips in practice, but will do for sure. In fact, minutes before I found a tip in StackOverflow about recompiling the widgetset with PRETTY style, but the info was incomplete so all in all this info is very useful.

Will give some feedback when I do further testing.

I’ve gone back to address this issue, but haven’t been able to get any success although I’ve followed your recommendations.

Removed every known listeners for my grid. Event the Selection one.

My app keeps hanging when I click on the CheckBox in the column header.

It looks to me like a Vaadin bug when the grid has a lot of rows (about 60.000 in my case).

There’s no loop inside the select() method of the SelectionListener.

If I click on the selector CheckBox on individual rows, debugger successfully stops on the breakpoints I placed inside the select() method in the SelectionListener.

Moreover - even though I recompiled the WidgetSet with the “pretty” setting, I haven’t been able to reproduce the “Uncaught client side exception” I was talking about on previous posts. Instead, the selection is properly made from botton to top. Then, when selection reaches the max selection row number I set previously, again debugger stops on a breakpoint inside the select() method. But nothing of this happens if I click on the column header CheckBox. Blue bar keeps growing and flashing forever. So I think the problem is not server side.

Another buggy or not-nice behaviour I experience is that, when I manually reach the max selection number (let’s say, 200) I previously set with .setSelectionLimit(), the UI will keep further rows look as being selected (checkbox checked, row with blue background), but no effective selection is made. Either the new rows shouldn’t look as “selected” or the previous selected ones should be deselected and then select the new ones, or some other logical behaviour, but not this.