protected void appendMainScriptTagContents(BootstrapContext context, StringBuilder builder) throws IOException { JsonObject appConfig = context.getApplicationParameters(); boolean isDebug = !context.getSession().getConfiguration() .isProductionMode(); if (isDebug) { /* * Add tracking needed for getting bootstrap metrics to the client * side Profiler if another implementation hasn't already been * added. */ builder.append( "if (typeof window.__gwtStatsEvent != 'function') {\n"); builder.append("vaadin.gwtStatsEvents = [];\n"); builder.append( "window.__gwtStatsEvent = function(event) {vaadin.gwtStatsEvents.push(event); return true;};\n"); builder.append("}\n"); } builder.append("vaadin.initApplication(\""); builder.append(context.getAppId()); builder.append("\","); appendJsonObject(builder, appConfig, isDebug); builder.append(");\n"); }
context.getSession().getCommunicationManager(), new FilterContext(context.getSession())); for (Dependency dependency : deps) { Type type = dependency.getType();
Document document = Document.createShell(""); BootstrapPageResponse pageResponse = new BootstrapPageResponse(this, request, context.getSession(), context.getUIClass(), document, headers, fragmentResponse.getUIProvider()); pageResponse.setUriResolver(context.getUriResolver()); context.getSession().modifyBootstrapResponse(pageResponse);
protected static JsonObject getApplicationParameters( BootstrapContext context) { VaadinRequest request = context.getRequest(); VaadinSession session = context.getSession(); VaadinService vaadinService = request.getService(); final boolean productionMode = session.getConfiguration() Locale locale = ServletHelper.findLocale(context.getSession(), context.getRequest());
+ "}"); if (context.getSession().getBrowser().isPhantomJS()) {
private static String getBootstrapJS(JsonValue initialUIDL, BootstrapContext context) { boolean productionMode = context.getSession().getConfiguration() .isProductionMode(); String result = getBootstrapJS(); JsonObject appConfig = context.getApplicationParameters(); int indent = 0; if (!productionMode) { indent = 4; } String appConfigString = JsonUtil.stringify(appConfig, indent); String initialUIDLString = JsonUtil.stringify(initialUIDL, indent); // Browser interpret </script> as end of script no matter if it is // inside a string or not so we must escape it initialUIDLString = scriptEndTagPattern.matcher(initialUIDLString) .replaceAll("<\\\\x2F$1"); if (!productionMode) { // only used in debug mode by profiler result = result.replace("{{GWT_STAT_EVENTS}}", GWT_STAT_EVENTS_JS); } else { result = result.replace("{{GWT_STAT_EVENTS}}", ""); } result = result.replace("{{APP_ID}}", context.getAppId()); result = result.replace("{{INITIAL_UIDL}}", initialUIDLString); result = result.replace("{{CONFIG_JSON}}", appConfigString); return result; }
private static String getClientEngineUrl(BootstrapContext context) { // use nocache version of client engine if it // has been compiled by SDM or eclipse // In production mode, this should really be loaded by the static block // so emit a warning if we get here (tests will always get here) final boolean productionMode = context.getSession().getConfiguration() .isProductionMode(); boolean resolveNow = !productionMode || clientEngineFile == null; if (resolveNow && BootstrapHandler.class.getResource( "/META-INF/resources/" + CLIENT_ENGINE_NOCACHE_FILE) != null) { return context.getUriResolver().resolveVaadinUri( "context://" + CLIENT_ENGINE_NOCACHE_FILE); } if (clientEngineFile == null) { throw new BootstrapException( "Client engine file name has not been resolved during initialization"); } return context.getUriResolver() .resolveVaadinUri("context://" + clientEngineFile); }
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());
/** * 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 getFrontendUrl() { if (frontendUrl == null) { frontendUrl = resolveFrontendUrl(context.getSession()); } return frontendUrl; } }