Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 1 month ago
extending VaadinCDIServlet
Hello,
I am attempting to create a responsive site using the @CDIUI annotation, the site works well except I need to add in the meta data for ios and other tablet/mobile devices. I found the tutorial on extending the Servlet which I have done, but I can not find how to add this to the app so it runs the MyServlet class instead of the VaadinCDIServlet class.
Here is the UI class:
@CDIUI( "" )
@Theme( "mytheme" )
@Widgetset( "AppWidgetset" )
public class Index extends UI
{
private static final long serialVersionUID = 7865189073630975648L;
@Inject
UserSession userSession;
@Inject
Instance<Login> login;
@Override
protected void init( VaadinRequest request )
{
...
}
void enter( String fragment )
{
...
}
}
Here is the Servlet class:
public class MyServlet extends VaadinCDIServlet
{
private static final long serialVersionUID = -493726102799793509L;
@Override
protected void servletInitialized() throws ServletException
{
super.servletInitialized();
getService().addSessionInitListener( new SessionInitListener() {
private static final long serialVersionUID = -3494654194281279732L;
@Override
public void sessionInit( SessionInitEvent event )
{
event.getSession().addBootstrapListener(
new BootstrapListener() {
private static final long serialVersionUID = 1163081932146335044L;
@Override
public void modifyBootstrapFragment( BootstrapFragmentResponse response )
{}
@Override
public void modifyBootstrapPage( BootstrapPageResponse response )
{
Attributes attr = new Attributes();
attr.put( "name", "viewport" );
attr.put( "content",
"width=device-width intial-scale=1, "
+ "maximum-scale=1 user-scalable=no" );
response.getDocument()
.head()
.appendChild(
new Element( Tag.valueOf( "meta" ), "",attr ) );
}
} );
}
} );
}
}
any guidance would be much appreciated
Many Thanks
Alex
Last updated on
Hi, try this:
@WebServlet(urlPatterns = "/*", name = "MyServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = Index.class, productionMode = false)
public class MyServlet extends VaadinCDIServlet
...
Last updated on
You cannot reply to this thread.