Table of contents
1.
Introduction
2.
Multiplatform Runtime
2.1.
Step 1: pom.xml configuration for Vaadin 7
2.2.
Step 2: Removing Legacy Servlets
2.3.
Step 3: Converting UIs
2.4.
Step-4: Converting UI parameters
2.4.1.
Other Parameters
2.5.
Step-5: Adding Legacy Components
2.5.1.
Adding new views
3.
Frequently Asked Questions
3.1.
List several stages involved in Vaadin’s Security Architecture.
3.2.
How does Vaadin take care of its Routing and Navigation features?
3.3.
How would you construct mobile apps with Vaadin?
3.4.
How would you judge Vaadin’s capability to handle huge applications?
4.
Conclusion
Last Updated: Mar 27, 2024
Medium

Multiplatform Runtime

Author Rupal Saluja
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Many of you do not know that Vaadin’s development was initially started as an adapter. It was first released in the year 2002. It led to the introduction of a client-communication and rendering engine based on Ajax. This concept’s development started as a commercial product separately in 2006. It was previously named IT Mill Toolkit.

In May 2009, its founders changed its name to Vaadin Framework, and from that time onwards, that name never changed; it is still known as Vaadin. In 2010, they opened a directory in the name of Vaadin and added a channel. 

context of introduction

There are several tools of Vaadin which make it quite easy to operate. Therefore, it is now one of the most preferred platforms used for web development. In this blog, we will discuss one such tool of Vaadin, Multiplatform Runtime, in detail.

logo of vaadin

Multiplatform Runtime

The name Multiplatform Runtime suggests the involvement of multiple platforms. It allows components and applications written inside lower versions of Vaadin to run inside its higher versions. That is, any component inside Vaadin 7 will be able to run inside Vaadin 10+ application.

notion of multiplatform runtime

We will discuss the process of implying the Multiplatform Runtime tool step by step. Here, we have referred to Vaadin version 7. The process is similar for Vaadin version 8.

Step 1: pom.xml configuration for Vaadin 7

The pom.xml configuration for Vaadin 7 is the first step in setting up the Vaadin 7 application. After completing the process, the application will be able to run inside Vaadin 10+ versions. 

Firstly, you need to set up Maven. For that, define the platform version using the XML code given below.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-bom</artifactId>
            <type>pom</type>
            <scope>import</scope>
            <version>23.2.1</version>
        </dependency>
    </dependencies>
</dependencyManagement>


Then, declare the vaadin-core and mpr-v7 attributes using the XML code below.

<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-core</artifactId>
</dependency>
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>mpr-v7</artifactId>
</dependency>


For successful configuration, follow the steps further.

🍂 Framework Dependency

You can use the code below to define the required framework dependencies needed for the configuration. The minimum version mandatory for Vaadin 7 is 7.7.14 or newer.

<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-server</artifactId>
    <version>7.7.17</version>
    <exclusions>
        <exclusion>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-elemental</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-themes</artifactId>
    <version>7.7.17</version>
</dependency>


🍂 Maven Plugins

The Maven Plugins are added in the build section. It helps the configuration to manage the custom legacy widgetset. Here, we have referred to Vaadin version 7.7.14. The process is similar to other Vaadin versions.

You can use the following XML code to induce Maven Plugins.

<build>
     <plugins>
         <plugin>
             <groupId>com.vaadin</groupId>
             <artifactId>vaadin-maven-plugin</artifactId>
             <version>7.7.17</version>
             <executions>
                 <execution>
                     <goals>
                         <goal>resources</goal>
                         <goal>update-widgetset</goal>
                         <goal>compile</goal>
                     </goals>
                 </execution>
             </executions>
         </plugin>
     </plugins>
 </build>


🍂 Logging

We should add any slf4j dependency to the project to display flow application logs. You can use the XML code below to do it most easily.

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.25</version>
</dependency>

Step 2: Removing Legacy Servlets

The Multiplatform Runtime tool manages the VaadinServlets to ensure that requests are routed to the appropriate frameworks. For that, it removes all legacy VaadinServlets, which may hamper its performance.

You can use the VaadinServlet provided by Vaadin flow in case you want some customized functionality.

Step 3: Converting UIs

You can replace the UI Class with a Vaadin Flow component when not using a navigator. We can do this by changing init(VaadinRequest) to a constructor and having UI.setContent be added in (new LegacyWrapper(content)).

Refer to the Java code example below for a better understanding.

From this: 

@Theme("valo")
public class AddressbookUI extends UI
{
    private HorizontalLayout content = new HorizontalLayout();
    @Override
    protected void init(VaadinRequest vaadinRequest)
    {
        content.setSizeFull();
        setContent(content);
    }
}

 

To this:

@Route("")
public class AddressbookLayout extends Div
{
    private HorizontalLayout content = new HorizontalLayout();
    public AddressbookLayout()
    {
        content.setSizeFull();
        add(new LegacyWrapper(content));
    }
}


You can use the HasLegacyComponents interface, so you do not need to use the new LegacyWrapper class. This makes the code look easier.

@Route("")
public class AddressbookLayout extends Div implements HasLegacyComponents
{
    private HorizontalLayout content = new HorizontalLayout();
    public AddressbookLayout()
    {
        content.setSizeFull();
        add(content);
    }
}

Step-4: Converting UI parameters

This step is completely dependent on your original UI. So, the configuration one will have to perform is decided by their choice. The list of choices that one could opt for is mentioned below.

  • Using a Custom Widgetset
  • Using a Custom Theme
  • Using Push
  • Managing the VaadinSessions
  • Using an advanced custom UI logic
     

Other Parameters

There are two other parameters that one should take into consideration. Both of these are explained briefly below.

@Title: For this parameter, you must use @PageTitle from the com.vaadin.flow.router package.

@Viewport: For this parameter, you must use @ViewPort from com.vaadin.flow.component.page package.

After you are done with the conversion, proceed to the next step.

Step-5: Adding Legacy Components

You have everything required to make a Vaadin 7 or 8 application run inside Vaadin 10+ versions. Since it is a flow application, you can add legacy components to the layout along with flow components. You need to create them and add them dynamically.

You can use the following example Java code for your reference.

add(new com.vaadin.flow.component.html.NativeButton("Flow button that adds a FW7 Label",e ->
{
    add(new LegacyWrapper(new com.vaadin.ui.Label("Legacy label")));
}));
add(new LegacyWrapper(new com.vaadin.ui.NativeButton("Legacy button that adds a Flow Label", e ->
{
    add(new com.vaadin.flow.component.html.Label("Flow label"));
}))); 

 

Adding new views

Views are managed by the @Route annotation primarily. These are also known as RouteTargets. It is advisable to add new views added to the application must follow Vaadin’s routing system. For more information on this topic, please refer to our blog on Routing and Navigation.

You are done with building the application and running it with Multiplatform Runtime. Next, you must consider packaging it for production ahead.

Frequently Asked Questions

List several stages involved in Vaadin’s Security Architecture.

The several stages involved in Vaadin’s Security Architecture are Application State, Data Validation, Web Services, SSL, and HTTPS functions.

How does Vaadin take care of its Routing and Navigation features?

Routing in Vaadin refers to its ability to attach views to particular URLs to maintain useful deep linking. Deep linking means users can share direct links to whichever view and state they want.

While navigation is the process of passing through those views included in routing for any specific purpose.

How would you construct mobile apps with Vaadin?

Creating mobile applications with Vaadin is easy because all Vaadin components are mobile-first. That means they adjust to several viewport widths providing the best touch screen experience.

Also, Vaadin apps are PWAs by default. So users can install them on their Android and iOS devices. 

How would you judge Vaadin’s capability to handle huge applications?

Vaadin marks that many of their clients have created applications with many views. When using the server-side Flow framework, the client JavaScript size becomes independent of the app size. Therefore a multiple-view application loads just as furious as a single-view application.

Conclusion

To cut short, we understood Multiplatform Runtime and learned various steps involved in its implications. This includes pom.xml configuration, removing legacy servlets, converting UIs, converting UI parameters, and adding legacy components.

We hope the above discussion helped you understand Multiplatform Runtime clearer and can be used for future reference whenever needed. To learn more about Vaadin and its components, you can refer to blogs on Vaadin-Design System ResourcesVaadin-Core ElementsConfirm Dialog, and Combo Box.

Visit our website to read more such blogs. Make sure that you enroll in the courses we provide, take mock tests, solve problems available, and interview puzzles. Also, you can pay attention to interview stuff- interview experiences and an interview bundle for placement preparations. Do upvote our blog to help fellow ninjas grow.

Happy Coding!

Live masterclass