Include a custom (meta) line on header section of html

Hello,

This is my first post…
I am from Portugal, and I am testing Vaadin framework.
I want to congratulate the team for the great work.

Maybe this is a basic question… but…
In the middle of the tests i need to put the line:

<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">

on the head section of html page.

How should i do it?

Hi, and welcome!

You can extend ApplicationServlet and override writeAjaxPageHtmlHeader method. You can add your custom meta tag there.

Thanks for the answer and for the speed of it!
Actually i already had EE6ApplicationServlet… for “no xml” configuration file:


package com.example.noxml;

import com.vaadin.terminal.gwt.server.ApplicationServlet;
import java.io.BufferedWriter;
import java.io.IOException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;

@SuppressWarnings("serial")
@WebServlet(name = "Sample Application",
initParams = {
    @WebInitParam(name = "application",
    value = "com.example.noxml.EntryPoint")
},
urlPatterns = {"/*"})
public class EE6ApplicationServlet extends ApplicationServlet {

    @Override
    protected void writeAjaxPageHtmlHeader(BufferedWriter page, String title, String themeUri) throws IOException {
        super.writeAjaxPageHtmlHeader(page, title, themeUri);
        page.append("<meta name=\"viewport\" content=\"width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;\">");
    }
}