Skip to content

Instantly share code, notes, and snippets.

@mstahv
Created March 22, 2016 07:45
Show Gist options
  • Save mstahv/4f5b55457a96a8441834 to your computer and use it in GitHub Desktop.
Save mstahv/4f5b55457a96a8441834 to your computer and use it in GitHub Desktop.
Yet another example to add lang attribute to html tag, this time with Viritin add-on
package org.test;
import javax.servlet.annotation.WebServlet;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import org.vaadin.viritin.util.HtmlElementPropertySetter;
/**
* A UI example to set lang attr to document element
*/
@Theme("mytheme")
public class MyUI extends UI {
@Override
protected void init(VaadinRequest vaadinRequest) {
// HtmlElementPropertySetter is part of Viritin add-on https://vaadin.com/directory#!addon/viritin
HtmlElementPropertySetter heps = new HtmlElementPropertySetter(this);
heps.setProperty("//html", "lang", "fr");
setContent(new Label("Hello lang attr"));
}
@WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
public static class MyUIServlet extends VaadinServlet {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment