Inform server side when client part becomes visible

Hello at all,

I am using Vaadin 8 and I have written my own AddOn with a server and a client part. On server side I need the info, when client part becomes visible (for example the AddOn is used in a TabSheet and the Tab becomes visible again). Therefore I have overidden method markAsDirtyRecursive() from AbstractClientConnector. It works quite fine.
But sometimes I have some trouble with my AddOn. It looks like that the method markAsDirtyRecursive() is not called (I can only make logging entries because the error only occurs in the production environment). Can it be?
Are there other possibilities to get the needed information? Method attach() is not feasible because it is only called once and not every time, when the AddOn becomes visible.

Thanks a lot

It depends what you mean by becoming visible. From one angle I have studied this problem myself too. As a result I wrote this add-on, which I call ViewPortExtension. You can extended a component with it and you can the have a e.g. event when component’s view port visibility status changes. Btw, I have not used it with TabSheet yet.

https://vaadin.com/directory/component/viewportextension-add-on

Hi,

I try to explain it in more detail. My AddOn represents a very extended Gantt chart with, in some cases, many 10,000 datasets. When it is opened all needed data like zoom factors, colors, data itself and so on are send to the client via state. Afterwards, while continue working, I clean up the state and send only changed datasets via state to the client to reduce size of the data. Because in most cases only 1 - 5 datasets changes.
When you make the AddOn invisible via changing the surrounding tabsheet e.g. all stuff on client side is destroyed by the framework. Therefore I have to re-send all data (like the first opening) when the AddOn/surrounding tabsheet gets visible again. That means in my case I have to put all data in state again.
To get knowledge about the re-opening I have overridden method markAsDirtyRecursive() and since years I have no problems with it. But suddenly it does not work in the production environment in one of our customers anymore. It looks like, that markAsDirtyRecursive() is not called everytime when it should be called (or my logging is wrong). And I have no idea why… And I can’t reproduce this behaviour in my environment. And this error only occurs fortuitously. Sometimes everything is fine and sometimes not.
For sure, I can override onStateCanged() and if it is initial I can make a RPC call to inform the server side but maybe there is a better way to solve my issue.
Is it possible with your mentioned viewport extension?

Thanks

Hi,

I tried your AddOn. The ViewPortStatusChangedListeners gets the info, whenn my AddOn is attached or when it becomes visible again after changing the tabs. But in my cases the listener is called three times. First with isInViewPort false, second and third time with true.
Is it always the same behaviour, because I only want to do my thinks one times. So I could do my stuff during first call with isInViewPort = false.