Google Analytics for Cuba 7.1+

Hi!

I’m planning to use this Vaadin add-on.

https://vaadin.com/directory#!addon/googleanalyticstracker

But when I tried this code below, I get an error:

    com.vaadin.ui.Window mainWindow = getWindow().unwrap(com.vaadin.ui.Window.class);

Error:
java.lang.ClassCastException: com.haulmont.cuba.web.widgets.CubaVerticalActionsLayout cannot be cast to com.vaadin.ui.Window

What should be the correct way to get com.vaadin.ui.Window from the current window?

Thanks!

Hi,

try something like:

Layout layout = workArea.getInitialLayout().unwrap(Layout.class);
layout.addComponent(yourVaadinComponent);

Hi Sanchit,

Sorry but I need to access the Window class… not the Layout.
Is there a way to get Window from Layout?
This is the Vaadin sample code to use this plugin.

 Window mainWindow = new Window(
            "GoogleanAlyticsWidget Sample Application");

    // A meaningless Label just to add some content
    Label label = new Label("Hello Vaadin user");
    mainWindow.addComponent(label);

    // Create a tracker for vaadin.com domain.
    GoogleAnalyticsTracker tracker = new GoogleAnalyticsTracker("UA-658457-8",
            "vaadin.com");

    // Add only one tracker per window.
    mainWindow.addComponent(tracker);

    // Track the page view
    tracker.trackPageview("/samplecode/googleanalytics");

    // Assign main window
    setMainWindow(mainWindow);

Thanks!