From 0be23936ef259c5b44ec51645879cd0830a8d711 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Thu, 22 Dec 2011 09:37:43 +0200 Subject: [PATCH] Rename AjaxPageHandler -> BootstrapHandler --- .../server/AbstractApplicationServlet.java | 2 +- .../server/AbstractCommunicationManager.java | 28 ++++----- ...PageHandler.java => BootstrapHandler.java} | 62 +++++++++---------- .../gwt/server/CommunicationManager.java | 10 +-- .../server/PortletCommunicationManager.java | 18 +++--- 5 files changed, 60 insertions(+), 60 deletions(-) rename src/com/vaadin/terminal/gwt/server/{AjaxPageHandler.java => BootstrapHandler.java} (91%) diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index b2d3a7f89f..188e35fc2a 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -805,7 +805,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements /* * UIDL request contains valid repaintAll=1 event, the user probably * wants to initiate a new application through a custom index.html - * without using writeAjaxPage. + * without using the bootstrap page. */ return true; diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 71a783f125..021908ab6e 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -62,7 +62,7 @@ import com.vaadin.terminal.VariableOwner; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedResponse; import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.server.AjaxPageHandler.AjaxPageContext; +import com.vaadin.terminal.gwt.server.BootstrapHandler.BootstrapContext; import com.vaadin.terminal.gwt.server.ComponentSizeValidator.InvalidLayout; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractField; @@ -185,7 +185,7 @@ public abstract class AbstractCommunicationManager implements */ public AbstractCommunicationManager(Application application) { this.application = application; - application.addRequestHandler(getAjaxPageHandler()); + application.addRequestHandler(getBootstrapHandler()); application.addRequestHandler(APP_RESOURCE_HANDLER); requireLocale(application.getLocale().toString()); } @@ -1907,7 +1907,7 @@ public abstract class AbstractCommunicationManager implements private final HashMap, Integer> typeToKey = new HashMap, Integer>(); private int nextTypeKey = 0; - private AjaxPageHandler ajaxPageHandler; + private BootstrapHandler bootstrapHandler; String getTagForType(Class class1) { Integer object = typeToKey.get(class1); @@ -1949,20 +1949,20 @@ public abstract class AbstractCommunicationManager implements abstract protected void cleanStreamVariable(VariableOwner owner, String name); /** - * Gets the ajax page handler that should be used for generating ajax pages - * for this communication manager. + * Gets the bootstrap handler that should be used for generating the pages + * bootstrapping applications for this communication manager. * - * @return the ajax page handler to use + * @return the bootstrap handler to use */ - private AjaxPageHandler getAjaxPageHandler() { - if (ajaxPageHandler == null) { - ajaxPageHandler = createAjaxPageHandler(); + private BootstrapHandler getBootstrapHandler() { + if (bootstrapHandler == null) { + bootstrapHandler = createBootstrapHandler(); } - return ajaxPageHandler; + return bootstrapHandler; } - protected abstract AjaxPageHandler createAjaxPageHandler(); + protected abstract BootstrapHandler createBootstrapHandler(); protected boolean handleApplicationRequest(WrappedRequest request, WrappedResponse response) throws IOException { @@ -1986,13 +1986,13 @@ public abstract class AbstractCommunicationManager implements response.setContentType("application/json; charset=UTF-8"); // Use the same logic as for determined roots - AjaxPageHandler ajaxPageHandler = getAjaxPageHandler(); - AjaxPageContext context = ajaxPageHandler.createContext( + BootstrapHandler bootstrapHandler = getBootstrapHandler(); + BootstrapContext context = bootstrapHandler.createContext( combinedRequest, response, application, root.getRootId()); String widgetset = context.getWidgetsetName(); String theme = context.getThemeName(); - String themeUri = ajaxPageHandler.getThemeUri(context, theme); + String themeUri = bootstrapHandler.getThemeUri(context, theme); // TODO These are not required if it was only the init of the root // that was delayed diff --git a/src/com/vaadin/terminal/gwt/server/AjaxPageHandler.java b/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java similarity index 91% rename from src/com/vaadin/terminal/gwt/server/AjaxPageHandler.java rename to src/com/vaadin/terminal/gwt/server/BootstrapHandler.java index f006708d0c..cfd65aa6f7 100644 --- a/src/com/vaadin/terminal/gwt/server/AjaxPageHandler.java +++ b/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java @@ -24,12 +24,12 @@ import com.vaadin.terminal.WrappedResponse; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.ui.Root; -public abstract class AjaxPageHandler implements RequestHandler { +public abstract class BootstrapHandler implements RequestHandler { /** Cookie used to ignore browser checks */ private static final String FORCE_LOAD_COOKIE = "vaadinforceload=1"; - protected class AjaxPageContext implements Serializable { + protected class BootstrapContext implements Serializable { private final WrappedResponse response; private final WrappedRequest request; private final Application application; @@ -43,7 +43,7 @@ public abstract class AjaxPageHandler implements RequestHandler { private boolean rootFetched = false; - public AjaxPageContext(WrappedResponse response, + public BootstrapContext(WrappedResponse response, WrappedRequest request, Application application, int rootId) { this.response = response; this.request = request; @@ -147,7 +147,7 @@ public abstract class AjaxPageHandler implements RequestHandler { } try { - writeAjaxPage(request, response, application, rootId); + writeBootstrapPage(request, response, application, rootId); } catch (JSONException e) { writeError(response, e); } @@ -194,28 +194,28 @@ public abstract class AjaxPageHandler implements RequestHandler { page.close(); } - protected final void writeAjaxPage(WrappedRequest request, + protected final void writeBootstrapPage(WrappedRequest request, WrappedResponse response, Application application, int rootId) throws IOException, JSONException { - AjaxPageContext context = createContext(request, response, application, - rootId); + BootstrapContext context = createContext(request, response, + application, rootId); DeploymentConfiguration deploymentConfiguration = request .getDeploymentConfiguration(); boolean standalone = deploymentConfiguration.isStandalone(request); if (standalone) { - setAjaxPageHeaders(context); - writeAjaxPageHtmlHeadStart(context); - writeAjaxPageHtmlHeader(context); - writeAjaxPageHtmlBodyStart(context); + setBootstrapPageHeaders(context); + writeBootstrapPageHtmlHeadStart(context); + writeBootstrapPageHtmlHeader(context); + writeBootstrapPageHtmlBodyStart(context); } // TODO include initial UIDL in the scripts? - writeAjaxPageHtmlVaadinScripts(context); + writeBootstrapPageHtmlVaadinScripts(context); - writeAjaxPageHtmlMainDiv(context); + writeBootstrapPageHtmlMainDiv(context); Writer page = context.getWriter(); if (standalone) { @@ -225,14 +225,14 @@ public abstract class AjaxPageHandler implements RequestHandler { page.close(); } - public AjaxPageContext createContext(WrappedRequest request, + public BootstrapContext createContext(WrappedRequest request, WrappedResponse response, Application application, int rootId) { - AjaxPageContext context = new AjaxPageContext(response, request, + BootstrapContext context = new BootstrapContext(response, request, application, rootId); return context; } - protected String getMainDivStyle(AjaxPageContext context) { + protected String getMainDivStyle(BootstrapContext context) { return null; } @@ -244,9 +244,9 @@ public abstract class AjaxPageHandler implements RequestHandler { * * @return the id to use in the DOM */ - protected abstract String getApplicationId(AjaxPageContext context); + protected abstract String getApplicationId(BootstrapContext context); - public String getWidgetsetForRoot(AjaxPageContext context) { + public String getWidgetsetForRoot(BootstrapContext context) { Root root = context.getRoot(); WrappedRequest request = context.getRequest(); @@ -272,7 +272,7 @@ public abstract class AjaxPageHandler implements RequestHandler { * * @throws IOException */ - protected void writeAjaxPageHtmlMainDiv(AjaxPageContext context) + protected void writeBootstrapPageHtmlMainDiv(BootstrapContext context) throws IOException { Writer page = context.getWriter(); String style = getMainDivStyle(context); @@ -332,7 +332,7 @@ public abstract class AjaxPageHandler implements RequestHandler { * * @throws IOException */ - protected void writeAjaxPageHtmlBodyStart(AjaxPageContext context) + protected void writeBootstrapPageHtmlBodyStart(BootstrapContext context) throws IOException { Writer page = context.getWriter(); page.write("\n\n\n\n"); } - protected void writeMainScriptTagContents(AjaxPageContext context) + protected void writeMainScriptTagContents(BootstrapContext context) throws JSONException, IOException { JSONObject defaults = getDefaultParameters(context); JSONObject appConfig = getApplicationParameters(context); @@ -403,7 +403,7 @@ public abstract class AjaxPageHandler implements RequestHandler { } } - protected JSONObject getApplicationParameters(AjaxPageContext context) + protected JSONObject getApplicationParameters(BootstrapContext context) throws JSONException, PaintException { Application application = context.getApplication(); int rootId = context.getRootId(); @@ -435,7 +435,7 @@ public abstract class AjaxPageHandler implements RequestHandler { return appConfig; } - protected JSONObject getDefaultParameters(AjaxPageContext context) + protected JSONObject getDefaultParameters(BootstrapContext context) throws JSONException { JSONObject defaults = new JSONObject(); @@ -487,7 +487,7 @@ public abstract class AjaxPageHandler implements RequestHandler { return defaults; } - protected abstract String getAppUri(AjaxPageContext context); + protected abstract String getAppUri(BootstrapContext context); /** * Method to write the contents of head element in html kickstart page. @@ -497,7 +497,7 @@ public abstract class AjaxPageHandler implements RequestHandler { * * @throws IOException */ - protected void writeAjaxPageHtmlHeader(AjaxPageContext context) + protected void writeBootstrapPageHtmlHeader(BootstrapContext context) throws IOException { Writer page = context.getWriter(); String themeName = context.getThemeName(); @@ -536,7 +536,7 @@ public abstract class AjaxPageHandler implements RequestHandler { * * @param context */ - protected void setAjaxPageHeaders(AjaxPageContext context) { + protected void setBootstrapPageHeaders(BootstrapContext context) { WrappedResponse response = context.getResponse(); // Window renders are not cacheable @@ -558,7 +558,7 @@ public abstract class AjaxPageHandler implements RequestHandler { * @param context * @throws IOException */ - protected void writeAjaxPageHtmlHeadStart(AjaxPageContext context) + protected void writeBootstrapPageHtmlHeadStart(BootstrapContext context) throws IOException { Writer page = context.getWriter(); @@ -583,7 +583,7 @@ public abstract class AjaxPageHandler implements RequestHandler { * * @return */ - public String getThemeUri(AjaxPageContext context, String themeName) { + public String getThemeUri(BootstrapContext context, String themeName) { WrappedRequest request = context.getRequest(); final String staticFilePath = request.getDeploymentConfiguration() .getStaticFileLocation(request); @@ -597,7 +597,7 @@ public abstract class AjaxPageHandler implements RequestHandler { * @param context * @return */ - public String getThemeName(AjaxPageContext context) { + public String getThemeName(BootstrapContext context) { return context.getApplication().getThemeForRoot(context.getRoot()); } @@ -607,7 +607,7 @@ public abstract class AjaxPageHandler implements RequestHandler { * @param context * @return */ - public String findAndEscapeThemeName(AjaxPageContext context) { + public String findAndEscapeThemeName(BootstrapContext context) { String themeName = getThemeName(context); if (themeName == null) { WrappedRequest request = context.getRequest(); diff --git a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java index 05b852445c..3a9b8ff2db 100644 --- a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java @@ -186,10 +186,10 @@ public class CommunicationManager extends AbstractCommunicationManager { } @Override - protected AjaxPageHandler createAjaxPageHandler() { - return new AjaxPageHandler() { + protected BootstrapHandler createBootstrapHandler() { + return new BootstrapHandler() { @Override - protected String getApplicationId(AjaxPageContext context) { + protected String getApplicationId(BootstrapContext context) { String appUrl = getAppUri(context); String appId = appUrl; @@ -210,7 +210,7 @@ public class CommunicationManager extends AbstractCommunicationManager { } @Override - protected String getAppUri(AjaxPageContext context) { + protected String getAppUri(BootstrapContext context) { /* Fetch relative url to application */ // don't use server and port in uri. It may cause problems with // some @@ -225,7 +225,7 @@ public class CommunicationManager extends AbstractCommunicationManager { } @Override - public String getThemeName(AjaxPageContext context) { + public String getThemeName(BootstrapContext context) { String themeName = context.getRequest().getParameter( AbstractApplicationServlet.URL_PARAMETER_THEME); if (themeName == null) { diff --git a/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java index 8f999ade5a..49bcb7a79c 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java @@ -118,8 +118,8 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { } @Override - protected AjaxPageHandler createAjaxPageHandler() { - return new AjaxPageHandler() { + protected BootstrapHandler createBootstrapHandler() { + return new BootstrapHandler() { @Override public boolean handleRequest(Application application, WrappedRequest request, WrappedResponse response) @@ -134,7 +134,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { } @Override - protected String getApplicationId(AjaxPageContext context) { + protected String getApplicationId(BootstrapContext context) { PortletRequest portletRequest = WrappedPortletRequest.cast( context.getRequest()).getPortletRequest(); /* @@ -145,11 +145,11 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { } @Override - protected String getAppUri(AjaxPageContext context) { + protected String getAppUri(BootstrapContext context) { return getRenderResponse(context).createActionURL().toString(); } - private RenderResponse getRenderResponse(AjaxPageContext context) { + private RenderResponse getRenderResponse(BootstrapContext context) { PortletResponse response = ((WrappedPortletResponse) context .getResponse()).getPortletResponse(); @@ -158,7 +158,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { } @Override - protected JSONObject getDefaultParameters(AjaxPageContext context) + protected JSONObject getDefaultParameters(BootstrapContext context) throws JSONException { /* * We need this in order to get uploads to work. TODO this is @@ -178,7 +178,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { } @Override - protected void writeMainScriptTagContents(AjaxPageContext context) + protected void writeMainScriptTagContents(BootstrapContext context) throws JSONException, IOException { // fixed base theme to use - all portal pages with Vaadin // applications will load this exactly once @@ -198,7 +198,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { } @Override - protected String getMainDivStyle(AjaxPageContext context) { + protected String getMainDivStyle(BootstrapContext context) { DeploymentConfiguration deploymentConfiguration = context .getRequest().getDeploymentConfiguration(); return deploymentConfiguration.getApplicationOrSystemProperty( @@ -215,7 +215,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { @Override protected JSONObject getApplicationParameters( - AjaxPageContext context) throws JSONException, + BootstrapContext context) throws JSONException, PaintException { JSONObject parameters = super.getApplicationParameters(context); WrappedPortletResponse wrappedPortletResponse = (WrappedPortletResponse) context -- 2.39.5