ValueChangeMode.EAGER

Hi,

I would need to set the time after which the data is transferred to the server after a change of the value.

In details: I have a textfield to enter an address. The address is geocoded on the server side. Currently I get a lot of ValueChangedEvents and the geocoding is triggered while the address is still typed in. I want to increase the timeout after which the change is sent to prevent geocoding of incomplete addresses. Is there already a property to set the timeout?

Interesting question! I experienced something similar with the Customer tutorial: the list keeps reloading while I’m still typing in the query text field. Eventually this will cause nasty looking exceptions like this:

[qtp770950500-16]
 ERROR com.vaadin.flow.server.DefaultErrorHandler - 
java.lang.IllegalArgumentException: Null values are not allowed for primitive types but a 'null' value was received for parameter 0 which refers to primitive type 'int' in the method 'setRequestedRange' defined in the class 'com.vaadin.flow.component.grid.Grid'
	at com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.decodeArg(PublishedServerEventHandlerRpcHandler.java:241)
	at com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.decodeArgs(PublishedServerEventHandlerRpcHandler.java:198)
	at com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.invokeMethod(PublishedServerEventHandlerRpcHandler.java:152)
	at com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.invokeMethod(PublishedServerEventHandlerRpcHandler.java:137)
	at com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.handleNode(PublishedServerEventHandlerRpcHandler.java:116)
	at com.vaadin.flow.server.communication.rpc.AbstractRpcInvocationHandler.handle(AbstractRpcInvocationHandler.java:63)
	at com.vaadin.flow.server.communication.ServerRpcHandler.handleInvocationData(ServerRpcHandler.java:377)
	at com.vaadin.flow.server.communication.ServerRpcHandler.lambda$handleInvocations$0(ServerRpcHandler.java:367)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at com.vaadin.flow.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:367)
	at com.vaadin.flow.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:309)
	at com.vaadin.flow.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:89)
	at com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
	at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1495)
	at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:300)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:835)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1685)
	at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:225)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
	at org.eclipse.jetty.server.Server.handle(Server.java:517)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
	at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
	at java.lang.Thread.run(Thread.java:748)

Andreas Bean:
Hi,

I would need to set the time after which the data is transferred to the server after a change of the value.

In details: I have a textfield to enter an address. The address is geocoded on the server side. Currently I get a lot of ValueChangedEvents and the geocoding is triggered while the address is still typed in. I want to increase the timeout after which the change is sent to prevent geocoding of incomplete addresses. Is there already a property to set the timeout?

I this case, why can’t you have your custom event handler keeps track of the time using some local variable on the server side? You can decide whether you want to decode the user input or not based on the time lag and/or number of characters alredy typed by the user.

On the server side I would need to start an async task which processes the value after a given time. If meanwhile the value is changed the async task has to be cancelled and restarted.

This means that I need to have an additional thread and sync to the UI thread and push the result to the client. This is a complex workaround compared to just set the timeout after which the value changed event is fired.

Please Vaadin Team add the possibility to set the timeout for the valuechangemode EAGER.

Syam Pillai:

Andreas Bean:
Hi,

I would need to set the time after which the data is transferred to the server after a change of the value.

In details: I have a textfield to enter an address. The address is geocoded on the server side. Currently I get a lot of ValueChangedEvents and the geocoding is triggered while the address is still typed in. I want to increase the timeout after which the change is sent to prevent geocoding of incomplete addresses. Is there already a property to set the timeout?

I this case, why can’t you have your custom event handler keeps track of the time using some local variable on the server side? You can decide whether you want to decode the user input or not based on the time lag and/or number of characters alredy typed by the user.

If I would use a variable on the serverside and decide that I skip the event. What’s your suggestion to handle the data in the case that this event was the last one?

This is still not solved. To anyone of the Vaadin team, please consider adding a parameter to set the timeout where the data is sent.

I don’t see any progress on this issue. It’s a blocker for me. Please provide a solution.

I think you should create a feature / bug request on github.
Perhaps you will have a feedback from Vaadin