if (app != null) {
PortletSession sess = request.getPortletSession();
PortletApplicationContext ctx = PortletApplicationContext
.getApplicationContext(sess);
PortletRequestDispatcher dispatcher = sess.getPortletContext()
.getRequestDispatcher("/" + app);
try {
// portal-wide settings
PortalContext portalCtx = request.getPortalContext();
boolean isLifeRay = portalCtx.getPortalInfo().toLowerCase()
.contains("liferay");
request.setAttribute(ApplicationServlet.REQUEST_FRAGMENT,
"true");
// fixed base theme to use - all portal pages with Vaadin
// applications will load this exactly once
String portalTheme = getPortalProperty(
Constants.PORTAL_PARAMETER_VAADIN_THEME, portalCtx);
String portalWidgetset = getPortalProperty(
Constants.PORTAL_PARAMETER_VAADIN_WIDGETSET, portalCtx);
// location of the widgetset(s) and default theme (to which
// /VAADIN/widgetsets/...
// is appended)
String portalResourcePath = getPortalProperty(
Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH,
portalCtx);
if (portalResourcePath != null) {
// if portalResourcePath is defined, set it as a request
// parameter which will override the default location in
// servlet
request.setAttribute(
ApplicationServlet.REQUEST_VAADIN_STATIC_FILE_PATH,
portalResourcePath);
}
// - if the user has specified a widgetset for this portlet, use
// it from the portlet (not fully supported)
// - otherwise, if specified, use the portal-wide widgetset
// and widgetset path settings (recommended)
// - finally, default to use the default widgetset if nothing
// else is found
if (portletWidgetset != null) {
request.setAttribute(ApplicationServlet.REQUEST_WIDGETSET,
portletWidgetset);
}
if (portalWidgetset != null) {
request.setAttribute(
ApplicationServlet.REQUEST_SHARED_WIDGETSET,
portalWidgetset);
}
if (style != null) {
request.setAttribute(ApplicationServlet.REQUEST_APPSTYLE,
style);
}
// portalTheme is only used if the shared portal resource
// directory is defined
if (portalTheme != null && portalResourcePath != null) {
request.setAttribute(
ApplicationServlet.REQUEST_DEFAULT_THEME,
portalTheme);
String defaultThemeUri = null;
defaultThemeUri = portalResourcePath + "/"
+ AbstractApplicationServlet.THEME_DIRECTORY_PATH
+ portalTheme;
/*
* Make sure portal default Vaadin theme is included in DOM.
* Vaadin portlet themes do not "inherit" base theme, so we
* need to force loading of the common base theme.
*/
OutputStream out = response.getPortletOutputStream();
// Using portal-wide theme
String loadDefaultTheme = ("<script type=\"text/javascript\">\n"
+ "if(!vaadin) { var vaadin = {} } \n"
+ "if(!vaadin.themesLoaded) { vaadin.themesLoaded = {} } \n"
+ "if(!vaadin.themesLoaded['"
+ portalTheme
+ "']) {\n"
+ "var stylesheet = document.createElement('link');\n"
+ "stylesheet.setAttribute('rel', 'stylesheet');\n"
+ "stylesheet.setAttribute('type', 'text/css');\n"
+ "stylesheet.setAttribute('href', '"
+ defaultThemeUri
+ "/styles.css');\n"
+ "document.getElementsByTagName('head')[0].appendChild(stylesheet);\n"
+ "vaadin.themesLoaded['"
+ portalTheme
+ "'] = true;\n}\n" + "</script>\n");
out.write(loadDefaultTheme.getBytes());
}
dispatcher.include(request, response);
if (isLifeRay) {
/*
* Temporary support to heartbeat Liferay session when using
* Vaadin based portlet. We hit an extra xhr to liferay