@Override protected void appendMainScriptTagContents(BootstrapContext context, StringBuilder builder) throws IOException { // fixed base theme to use - all portal pages with Vaadin // applications will load this exactly once String portalTheme = ((VaadinPortletRequest) context.getRequest()) .getPortalProperty(VaadinPortlet.PORTAL_PARAMETER_VAADIN_THEME); if (portalTheme != null && !portalTheme.equals(context.getThemeName())) { String portalThemeUri = getThemeUri(context, portalTheme); // XSS safe - originates from portal properties builder.append("vaadin.loadTheme('").append(portalThemeUri) .append("');"); } super.appendMainScriptTagContents(context, builder); }
viewportContent = ReflectTools .createInstance(viewportGeneratorClass) .getViewport(context.getRequest()); } catch (Exception e) { throw new RuntimeException( new UICreateEvent(context.getRequest(), context.getUIClass())); if (title != null) { head.appendElement("title").appendText(title);
fragmentNodes.add(mainDiv); VaadinRequest request = context.getRequest(); if (context.getRequest().getService().getDeploymentConfiguration() .isProductionMode()) { pushJS += ApplicationConstants.VAADIN_PUSH_JS;
/** * Gets the service URL as a URL relative to the request URI. * * @param context * the bootstrap context * @return the relative service URL */ protected static String getServiceUrl(BootstrapContext context) { String pathInfo = context.getRequest().getPathInfo(); if (pathInfo == null) { return "."; } else { /* * Make a relative URL to the servlet by adding one ../ for each * path segment in pathInfo (i.e. the part of the requested path * that comes after the servlet mapping) */ return ServletHelper.getCancelingRelativePath(pathInfo); } }
public PushMode getPushMode() { if (pushMode == null) { pushMode = getUI().getPushConfiguration().getPushMode(); if (pushMode == null) { pushMode = getRequest().getService() .getDeploymentConfiguration().getPushMode(); } if (pushMode.isEnabled() && !getRequest().getService().ensurePushAvailable()) { /* * Fall back if not supported (ensurePushAvailable will log * information to the developer the first time this happens) */ pushMode = PushMode.DISABLED; } } return pushMode; }
private static Element getPushScript(BootstrapContext context) { VaadinRequest request = context.getRequest(); // Parameter appended to JS to bypass caches after version upgrade. String versionQueryParam = "?v=" + Version.getFullVersion(); // Load client-side dependencies for push support String pushJS = ServletHelper.getContextRootRelativePath(request) + "/"; if (request.getService().getDeploymentConfiguration() .isProductionMode()) { pushJS += ApplicationConstants.VAADIN_PUSH_JS; } else { pushJS += ApplicationConstants.VAADIN_PUSH_DEBUG_JS; } pushJS += versionQueryParam; return new Element(Tag.valueOf("script"), "") .attr("type", TYPE_TEXT_JAVASCRIPT).attr("src", pushJS); }
public String getAppId() { if (appId == null) { appId = getRequest().getService().getMainDivId(getSession(), getRequest()); } return appId; }
protected JsonObject getApplicationParameters(BootstrapContext context) { VaadinRequest request = context.getRequest(); VaadinSession session = context.getSession(); VaadinService vaadinService = request.getService(); context.getSession(), context.getRequest());
private String getBootstrapHtml(BootstrapContext context) { VaadinRequest request = context.getRequest(); VaadinResponse response = context.getResponse(); VaadinService vaadinService = request.getService();
/** * Gets the push mode to use. * * @return the desired push mode */ public PushMode getPushMode() { if (pushMode == null) { UICreateEvent event = new UICreateEvent(getRequest(), getUIClass()); pushMode = getBootstrapResponse().getUIProvider() .getPushMode(event); if (pushMode == null) { pushMode = getRequest().getService() .getDeploymentConfiguration().getPushMode(); } if (pushMode.isEnabled() && !getRequest().getService().ensurePushAvailable()) { /* * Fall back if not supported (ensurePushAvailable will log * information to the developer the first time this happens) */ pushMode = PushMode.DISABLED; } } return pushMode; }
@Override protected JsonObject getApplicationParameters(BootstrapContext context) { JsonObject parameters = super.getApplicationParameters(context); VaadinPortletResponse response = (VaadinPortletResponse) context .getResponse(); VaadinPortletRequest request = (VaadinPortletRequest) context .getRequest(); MimeResponse portletResponse = (MimeResponse) response .getPortletResponse(); ResourceURL resourceURL = portletResponse.createResourceURL(); resourceURL.setResourceID("v-browserDetails"); parameters.put("browserDetailsUrl", resourceURL.toString()); String serviceUrlParameterName = ApplicationConstants.V_RESOURCE_PATH; // If we are running in Liferay then we need to prefix all parameters // with the portlet namespace if (request instanceof VaadinLiferayRequest) { serviceUrlParameterName = response.getPortletResponse() .getNamespace() + serviceUrlParameterName; } parameters.put(ApplicationConstants.SERVICE_URL_PARAMETER_NAME, serviceUrlParameterName); return parameters; }
/** * Get the URI for the application theme. * * A portal-wide default theme is fetched from the portal shared resource * directory (if any), other themes from the portlet. * * @param context * @param themeName * * @return */ public String getThemeUri(BootstrapContext context, String themeName) { VaadinRequest request = context.getRequest(); final String staticFilePath = request.getService() .getStaticFileLocation(request); return staticFilePath + "/" + VaadinServlet.THEME_DIR_PATH + '/' + themeName; }
/** * Do not override. * * @param context * @return */ public String findAndEscapeThemeName(BootstrapContext context) { String themeName = getThemeName(context); if (themeName == null) { VaadinRequest request = context.getRequest(); themeName = request.getService().getConfiguredTheme(request); } // XSS preventation, theme names shouldn't contain special chars anyway. // The servlet denies them via url parameter. themeName = VaadinServlet.stripSpecialChars(themeName); return themeName; }
/** * Gets the application id. * * The application id is defined by * {@link VaadinService#getMainDivId(VaadinSession, VaadinRequest, Class)} * * @return the application id */ public String getAppId() { if (appId == null) { appId = getRequest().getService().getMainDivId(getSession(), getRequest(), getUIClass()); } return appId; }
@Override protected String getServiceUrl(BootstrapContext context) { String pathInfo = context.getRequest().getPathInfo(); if (pathInfo == null) { return null; } else { /* * Make a relative URL to the servlet by adding one ../ for each * path segment in pathInfo (i.e. the part of the requested path * that comes after the servlet mapping) */ return VaadinServletService.getCancelingRelativePath(pathInfo); } }
public WidgetsetInfo getWidgetsetForUI(BootstrapContext context) { VaadinRequest request = context.getRequest(); UICreateEvent event = new UICreateEvent(context.getRequest(), context.getUIClass()); WidgetsetInfo widgetset = context.getBootstrapResponse().getUIProvider() .getWidgetsetInfo(event); if (widgetset == null) { // TODO do we want to move WidgetsetInfoImpl elsewhere? widgetset = new WidgetsetInfoImpl( request.getService().getConfiguredWidgetset(request)); } return widgetset; }
/** * Override if required. * * @param context * @return */ public String getThemeName(BootstrapContext context) { UICreateEvent event = new UICreateEvent(context.getRequest(), context.getUIClass()); return context.getBootstrapResponse().getUIProvider().getTheme(event); }
@Override protected String getContextRootPath(BootstrapContext context) { return VaadinServletService .getContextRootRelativePath(context.getRequest()) + "/"; }
@Override public String getThemeName(BootstrapContext context) { String themeName = context.getRequest() .getParameter(VaadinServlet.URL_PARAMETER_THEME); if (themeName == null) { themeName = super.getThemeName(context); } return themeName; }
@Override protected String getMainDivStyle(BootstrapContext context) { VaadinService vaadinService = context.getRequest().getService(); return vaadinService.getDeploymentConfiguration() .getApplicationOrSystemProperty( VaadinPortlet.PORTLET_PARAMETER_STYLE, null); }