5.5.9.1. Working with Vaadin Components
In order to work directly with Vaadin components that implement interfaces of the visual components library in Web Client, use the following methods of the Component
interface:
-
unwrap()
– retrieves an underlying Vaadin component for a given CUBA component. -
unwrapComposition()
- retrieves a Vaadin component that is the outmost external container in the implementation of a given CUBA component. For simple components, such as Button, this method returns the same object asunwrap()
-com.vaadin.ui.Button
. For complex components, such as Table,unwrap()
will return the corresponding object -com.vaadin.ui.Table
, whileunwrapComposition()
will returncom.vaadin.ui.VerticalLayout
, which contains the table together with ButtonsPanel andRowsCount
defined with it.
The methods accept a class of the underlying component to be returned, for example:
com.vaadin.ui.TextField vTextField = textField.unwrap(com.vaadin.ui.TextField.class);
You can also use the unwrap()
and getComposition()
static methods of the WebComponentsHelper
class, passing a CUBA component into them.
Please note that if a screen is located in the project’s gui module, you can only work with generalized interfaces of CUBA components. In order to use unwrap()
you should either put the entire screen into the web module, or use the controller companions mechanism.