How to check in Vaadin 7 if scrollbar is visible or not for a certain component, for example for Panel
-
I don't think it is possible out-of-the-box with Vaadin but you could do some JavaScript, see [here](https://vaadin.com/docs/-/part/framework/advanced/advanced-javascript.html) and [here](http://stackoverflow.com/a/4814526/1063673). But why do you need to know whether scrollbars are visible? – Steffen Harbich Jul 17 '16 at 10:46
-
I'm using https://github.com/alump/GridStack component and would like to resize each component attached to GridStack according to its content. Right now I have no any solutions other than test scrollbar visibility – alexanoid Jul 17 '16 at 11:02
1 Answers
Any implementation of AbstractClientConnector can be extended with AbstractExtension: https://vaadin.com/api/com/vaadin/server/AbstractExtension.html
An extension is a possible way to extend the functionality of your component: https://vaadin.com/docs/-/part/framework/gwt/gwt-extension.html
Adding features to existing components by extending them by inheritance creates a problem when you want to combine such features. For example, one add-on could add spell-check to a TextField, while another could add client-side validation. Combining such add-on features would be difficult if not impossible. You might also want to add a feature to several or even to all components, but extending all of them by inheritance is not really an option. Vaadin includes a component plug-in mechanism for these purposes. Such plug-ins are simply called extensions.
In the client-side extension implementation you can write your custom GWT code like following (pseudo code):
@Override
protected void extend(ServerConnector target) {
// Get the extended widget
final Widget widget = ((ComponentConnector) target).getWidget();
// register RPCs
YourServerRpcImplementation serverRpc = getRpcProxy(YourServerRpcImplementation.class); // client to server
registerRpc(YourClientRpcImplementation.class, this); // server to client, unused in this example
// add listener and update server state
Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
boolean scrollbarVisible = widget.getElement().getScrollHeight() > widget.getElement().getClientHeight();
serverRpc.yourEventMethod(scrollbarVisible);
}
});
}
Passing events between server and client: https://vaadin.com/docs/-/part/framework/gwt/gwt-rpc.html

- 689
- 8
- 25