Sfoglia il codice sorgente

Multiple changes for gwt terminals server side:

 * fixes #3181
 * improvement for #3054 (not a full fix)
 * removed mostly broken equals & hashCode methods from Web and Portlet contexts
 * refactoring


svn changeset:8480/svn branch:6.1
tags/6.7.0.beta1
Matti Tahvonen 15 anni fa
parent
commit
11d152a9ba

+ 16
- 1
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java Vedi File

@@ -304,7 +304,22 @@ public class ApplicationConnection {
console.log("Making UIDL Request with params: " + requestData);
String uri = getAppUri() + "UIDL" + configuration.getPathInfo();
if (repaintAll) {
uri += "?repaintAll=1";
int clientHeight = Window.getClientHeight();
int clientWidth = Window.getClientWidth();
com.google.gwt.dom.client.Element pe = view.getElement()
.getParentElement();
int offsetHeight = pe.getOffsetHeight();
int offsetWidth = pe.getOffsetWidth();
int screenWidth = BrowserInfo.get().getScreenWidth();
int screenHeight = BrowserInfo.get().getScreenHeight();

// TODO figure out how client and view size could be used better on
// server. screen size can be accessed via Browser object, but other
// values currently only via transaction listener.
uri += "?repaintAll=1&" + "sh=" + screenHeight + "&sw="
+ screenWidth + "&cw=" + clientWidth + "&ch="
+ clientHeight + "&vw=" + offsetWidth + "&vh="
+ offsetHeight;
if (analyzeLayouts) {
uri += "&analyzeLayouts=1";
}

+ 10
- 0
src/com/vaadin/terminal/gwt/client/BrowserInfo.java Vedi File

@@ -222,4 +222,14 @@ public class BrowserInfo {
c.log("isIE() " + get().isIE());
}

public native int getScreenWidth()
/*-{
return $wnd.screen.width;
}-*/;

public native int getScreenHeight()
/*-{
return $wnd.screen.height;
}-*/;

}

+ 26
- 35
src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java Vedi File

@@ -115,9 +115,6 @@ public abstract class AbstractApplicationServlet extends HttpServlet {
/**
* If set, do not load the default theme but assume that loading it is
* handled e.g. by ApplicationPortlet.
*
* The default theme should be located in
* REQUEST_DEFAULT_THEME_URI/THEME_DIRECTORY_PATH/getDefaultTheme() .
*/
public static final String REQUEST_DEFAULT_THEME = ApplicationServlet.class
.getName()
@@ -412,14 +409,15 @@ public abstract class AbstractApplicationServlet extends HttpServlet {
/* Update browser information from the request */
webApplicationContext.getBrowser().updateBrowserProperties(request);

// Start the newly created application
startApplication(request, application, webApplicationContext);

/*
* Transaction starts. Call transaction listeners. Transaction end
* is called in the finally block below.
*/
webApplicationContext.startTransaction(application, request);

// TODO Add screen height and width to the GWT client

/* Handle the request */
if (requestType == RequestType.FILE_UPLOAD) {
applicationManager.handleFileUpload(request, response);
@@ -430,7 +428,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet {
return;
}

// Removes application if it has stopped (by thread,
// Removes application if it has stopped (mayby by thread or
// transactionlistener)
if (!application.isRunning()) {
endApplication(request, response, application);
@@ -795,9 +793,9 @@ public abstract class AbstractApplicationServlet extends HttpServlet {
}

/**
* Creates and starts a new application. This is not meant to be overridden.
* Override getNewApplication to create the application instance in a custom
* way.
* Creates a new application and registers it into WebApplicationContext
* (aka session). This is not meant to be overridden. Override
* getNewApplication to create the application instance in a custom way.
*
* @param request
* @return
@@ -808,15 +806,9 @@ public abstract class AbstractApplicationServlet extends HttpServlet {
throws ServletException, MalformedURLException {
Application newApplication = getNewApplication(request);

// Create application
final URL applicationUrl = getApplicationUrl(request);

// Initial locale comes from the request
Locale locale = request.getLocale();
HttpSession session = request.getSession();

// Start the newly created application
startApplication(session, newApplication, applicationUrl, locale);
final WebApplicationContext context = WebApplicationContext
.getApplicationContext(request.getSession());
context.addApplication(newApplication);

return newApplication;
}
@@ -864,7 +856,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet {
// no explicit theme for window defined
if (request.getAttribute(REQUEST_DEFAULT_THEME) != null) {
// the default theme is defined in request (by portal)
return (String) request.getAttribute(REQUEST_DEFAULT_THEME);
themeName = (String) request
.getAttribute(REQUEST_DEFAULT_THEME);
} else {
// using the default theme defined by Vaadin
themeName = getDefaultTheme();
@@ -993,29 +986,27 @@ public abstract class AbstractApplicationServlet extends HttpServlet {
throws ServletException;

/**
* Starts the application if it is not already running. Ensures the
* application is added to the WebApplicationContext.
* Starts the application if it is not already running.
*
* @param session
* @param request
* @param application
* @param applicationUrl
* @param locale
* @param webApplicationContext
* @throws ServletException
* @throws MalformedURLException
*/
private void startApplication(HttpSession session, Application application,
URL applicationUrl, Locale locale) throws ServletException {
if (application == null) {
throw new ServletException(
"Application is null and can't be started");
}
private void startApplication(HttpServletRequest request,
Application application, WebApplicationContext webApplicationContext)
throws ServletException, MalformedURLException {

if (!application.isRunning()) {
final WebApplicationContext context = WebApplicationContext
.getApplicationContext(session);
// final URL applicationUrl = getApplicationUrl(request);
context.addApplication(application);
// Create application
final URL applicationUrl = getApplicationUrl(request);

// Initial locale comes from the request
Locale locale = request.getLocale();
application.setLocale(locale);
application.start(applicationUrl, applicationProperties, context);
application.start(applicationUrl, applicationProperties,
webApplicationContext);
}
}


+ 0
- 16
src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java Vedi File

@@ -98,22 +98,6 @@ public class PortletApplicationContext extends WebApplicationContext implements
super.removeApplication(application);
}
@Override
public boolean equals(Object obj) {
if (portletSession == null) {
return super.equals(obj);
}
return portletSession.equals(obj);
}
@Override
public int hashCode() {
if (portletSession == null) {
return super.hashCode();
}
return portletSession.hashCode();
}
public void setPortletApplication(Portlet portlet, Application app) {
portletToApplication.put(portlet, app);
}

+ 0
- 17
src/com/vaadin/terminal/gwt/server/WebApplicationContext.java Vedi File

@@ -107,23 +107,6 @@ public class WebApplicationContext implements ApplicationContext,
return cx;
}

@Override
public boolean equals(Object obj) {
if (session == null) {
return false;
}

return session.equals(obj);
}

@Override
public int hashCode() {
if (session == null) {
return -1;
}
return session.hashCode();
}

/**
* Adds the transaction listener to this context.
*

+ 3
- 3
src/com/vaadin/terminal/gwt/server/WebBrowser.java Vedi File

@@ -64,9 +64,9 @@ public class WebBrowser implements Terminal {
browserApplication = agent;
}

final String sw = request.getParameter("screenWidth");
final String sh = request.getParameter("screenHeight");
if (sw != null && sh != null) {
final String sw = request.getParameter("sw");
if (sw != null) {
final String sh = request.getParameter("sh");
try {
screenHeight = Integer.parseInt(sh);
screenWidth = Integer.parseInt(sw);

Loading…
Annulla
Salva