Initiating action after frontend fully displayed

I am currently using the excellent WrappingGrid in https://vaadin.com/directory/component/gridextensionpack-add-on/1.1.1. But one problem I am having is that visually it does not look perfect when you load it that way from the backend. For instance, if I display a footer, it cuts off the bottom Grid row, and other little nuisances. Looking at the demo, they initiate the wrapping via a button on the frontend, and when I add such a button to my app, it works rather well. But I would like to trigger the same frontend action when it fully loads, and not require a user action. Is there a way to do that in Vaadin 7?

One trick that comes to mind is to initially enable UI polling with a relatively short interval and add a poll listener. This will lead to a request being sent from the client around the time when the initial render is completed and this request will trigger your poll listener. In that listener, you can add the component and disable polling since it won’t be needed any more.

Another option could be adding a JavaScript callback (https://vaadin.com/docs/v7/framework/advanced/advanced-javascript#advanced.javascript.callback) and calling that from the server side ((https://vaadin.com/docs/v7/framework/advanced/advanced-javascript#advanced.javascript.calling)) when the view is navigated into, e.g. in an attach listener. In the callback’s implementation, execute the same code as in the Button’s click listener.

The JavaScript idea is a good idea, but for one slight problem: I need to do it when the frontend is loaded/rendered. In other words, let’s say they click “Submit” for a new result set, after the page is initially loaded/attached. That new result set will not trigger “attach”, as it is already attached. Well, I guess I have not tried that, but I am pretty sure it won’t based on other things I have done in the past.

I have read the polling idea before, just never really liked it, so never tried it.

I JUST figured out yesterday that even if I give them a button to “wrap” and “unwrap” the header, I still get visual problems. Nothing really to do with my question, per se, but made me wonder if even my idea to trigger the button click when frontend rendered would even work.

True problem is that the WrappingGrid code seems to get confused as the the size of things between the header and footer. This is a separate question, so moving it to a new post.

Thanks.