
nz.co.senanque.vaadin.SpringAwareTouchKitServlet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of madura-vaadin-touchkit Show documentation
Show all versions of madura-vaadin-touchkit Show documentation
Code to support using Madura with Vaadin's Touchkit
The newest version!
package nz.co.senanque.vaadin;
import com.vaadin.addon.touchkit.settings.TouchKitSettings;
import com.vaadin.spring.server.SpringVaadinServlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* License: http://www.wtfpl.net
*
* @author Matti Tahvonen
*/
public class SpringAwareTouchKitServlet extends SpringVaadinServlet {
TouchKitSettings touchKitSettings;
protected void servletInitialized() throws ServletException {
super.servletInitialized();
touchKitSettings = new TouchKitSettings(getService());
}
@Override
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String pathInfo = request.getPathInfo();
if (pathInfo != null) {
if (pathInfo.endsWith("themes/touchkit/styles.css")) {
serveDummyFile(response, "max-age=1000000");
return;
} else if (pathInfo.endsWith("PING/")) {
serveDummyFile(response, "no-store, no-cache, max-age=0, must-revalidate");
return;
}
}
super.service(request, response);
}
private void serveDummyFile(HttpServletResponse response, String cacheControl)
throws IOException {
response.setContentType("text/css");
response.setHeader("Cache-Control", cacheControl);
response.getOutputStream().write("\n".getBytes());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy