summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/com/vaadin/terminal/gwt/client/ApplicationConnection.java90
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VView.java19
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java4
-rw-r--r--src/com/vaadin/ui/LoginForm.java5
4 files changed, 70 insertions, 48 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
index 75edf4ebe7..5b6d094474 100755
--- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -46,16 +46,16 @@ import com.vaadin.terminal.gwt.server.AbstractCommunicationManager;
* This is the client side communication "engine", managing client-server
* communication with its server side counterpart
* {@link AbstractCommunicationManager}.
- *
+ *
* Client-side widgets receive updates from the corresponding server-side
* components as calls to
* {@link Paintable#updateFromUIDL(UIDL, ApplicationConnection)} (not to be
* confused with the server side interface {@link com.vaadin.terminal.Paintable}
* ). Any client-side changes (typically resulting from user actions) are sent
* back to the server as variable changes (see {@link #updateVariable()}).
- *
+ *
* TODO document better
- *
+ *
* Entry point classes (widgetsets) define <code>onModuleLoad()</code>.
*/
public class ApplicationConnection {
@@ -74,6 +74,10 @@ public class ApplicationConnection {
public static final String VAR_ARRAYITEM_SEPARATOR = "\u001c";
public static final String UIDL_SECURITY_TOKEN_ID = "Vaadin-Security-Key";
+
+ // This indicates the whole page is generated by us (not embedded)
+ public static final String GENERATED_BODY_CLASSNAME = "v-generated-body";
+
/**
* @deprecated use UIDL_SECURITY_TOKEN_ID instead
*/
@@ -217,7 +221,7 @@ public class ApplicationConnection {
* <li><code>vaadin.postRequestHooks</code> is a map of functions which gets
* called after each XHR made by vaadin application. Note, that it is
* attaching js functions responsibility to create the variable like this:
- *
+ *
* <code><pre>
* if(!vaadin.postRequestHooks) {vaadin.postRequestHooks = new Object();}
* postRequestHooks.myHook = function(appId) {
@@ -228,7 +232,7 @@ public class ApplicationConnection {
* </pre></code> First parameter passed to these functions is the identifier
* of Vaadin application that made the request.
* </ul>
- *
+ *
* TODO make this multi-app aware
*/
private native void initializeClientHooks()
@@ -259,7 +263,7 @@ public class ApplicationConnection {
/**
* Runs possibly registered client side post request hooks. This is expected
* to be run after each uidl request made by Vaadin application.
- *
+ *
* @param appId
*/
private static native void runPostRequestHooks(String appId)
@@ -282,7 +286,7 @@ public class ApplicationConnection {
/**
* Checks if client side is in debug mode. Practically this is invoked by
* adding ?debug parameter to URI.
- *
+ *
* @return true if client side is currently been debugged
*/
public native static boolean isDebugMode()
@@ -306,7 +310,7 @@ public class ApplicationConnection {
/**
* Gets the application base URI. Using this other than as the download
* action URI can cause problems in Portlet 2.0 deployments.
- *
+ *
* @return application base URI
*/
public String getAppUri() {
@@ -470,7 +474,7 @@ public class ApplicationConnection {
/**
* Shows the communication error notification. The 'details' only go to the
* console for now.
- *
+ *
* @param details
* Optional details for debugging.
*/
@@ -552,7 +556,7 @@ public class ApplicationConnection {
/**
* This method is called after applying uidl change set to application.
- *
+ *
* It will clean current and queued variable change sets. And send next
* change set if it exists.
*/
@@ -572,7 +576,7 @@ public class ApplicationConnection {
/**
* Cleans given queue of variable changes of such changes that came from
* components that do not exist anymore.
- *
+ *
* @param variableBurst
*/
private void cleanVariableBurst(ArrayList<String> variableBurst) {
@@ -929,7 +933,7 @@ public class ApplicationConnection {
/**
* Returns Paintable element by its id
- *
+ *
* @param id
* Paintable ID
*/
@@ -963,12 +967,12 @@ public class ApplicationConnection {
/**
* This method sends currently queued variable changes to server. It is
* called when immediate variable update must happen.
- *
+ *
* To ensure correct order for variable changes (due servers multithreading
* or network), we always wait for active request to be handler before
* sending a new one. If there is an active request, we will put varible
* "burst" to queue that will be purged after current request is handled.
- *
+ *
*/
@SuppressWarnings("unchecked")
public void sendPendingVariableChanges() {
@@ -990,11 +994,11 @@ public class ApplicationConnection {
/**
* Build the variable burst and send it to server.
- *
+ *
* When sync is forced, we also force sending of all pending variable-bursts
* at the same time. This is ok as we can assume that DOM will never be
* updated after this.
- *
+ *
* @param pendingVariables
* Vector of variable changes to send
* @param forceSync
@@ -1149,9 +1153,9 @@ public class ApplicationConnection {
/**
* Update generic component features.
- *
+ *
* <h2>Selecting correct implementation</h2>
- *
+ *
* <p>
* The implementation of a component depends on many properties, including
* styles, component features, etc. Sometimes the user changes those
@@ -1159,21 +1163,21 @@ public class ApplicationConnection {
* the beginning of your updateFromUIDL -method automatically replaces your
* component with more appropriate if the requested implementation changes.
* </p>
- *
+ *
* <h2>Caption, icon, error messages and description</h2>
- *
+ *
* <p>
* Component can delegate management of caption, icon, error messages and
* description to parent layout. This is optional an should be decided by
* component author
* </p>
- *
+ *
* <h2>Component visibility and disabling</h2>
- *
+ *
* This method will manage component visibility automatically and if
* component is an instanceof FocusWidget, also handle component disabling
* when needed.
- *
+ *
* @param component
* Widget to be updated, expected to implement an instance of
* Paintable
@@ -1182,7 +1186,7 @@ public class ApplicationConnection {
* @param manageCaption
* True if you want to delegate caption, icon, description and
* error message management to parent.
- *
+ *
* @return Returns true iff no further painting is needed by caller
*/
public boolean updateComponent(Widget component, UIDL uidl,
@@ -1396,7 +1400,7 @@ public class ApplicationConnection {
/**
* Traverses recursively child widgets until ContainerResizedListener child
* widget is found. They will delegate it further if needed.
- *
+ *
* @param container
*/
private boolean runningLayout = false;
@@ -1459,7 +1463,7 @@ public class ApplicationConnection {
/**
* Converts relative sizes into pixel sizes.
- *
+ *
* @param child
* @return true if the child has a relative size
*/
@@ -1606,7 +1610,7 @@ public class ApplicationConnection {
/**
* Converts relative sizes into pixel sizes.
- *
+ *
* @param child
* @return true if the child has a relative size
*/
@@ -1623,12 +1627,12 @@ public class ApplicationConnection {
/**
* Get either existing or new Paintable for given UIDL.
- *
+ *
* If corresponding Paintable has been previously painted, return it.
* Otherwise create and register a new Paintable from UIDL. Caller must
* update the returned Paintable from UIDL after it has been connected to
* parent.
- *
+ *
* @param uidl
* UIDL to create Paintable from.
* @return Either existing or new Paintable corresponding to UIDL.
@@ -1648,7 +1652,7 @@ public class ApplicationConnection {
/**
* Returns a Paintable element by its root element
- *
+ *
* @param element
* Root element of the paintable
*/
@@ -1662,7 +1666,7 @@ public class ApplicationConnection {
/**
* Singleton method to get instance of app's context menu.
- *
+ *
* @return VContextMenu object
*/
public VContextMenu getContextMenu() {
@@ -1678,7 +1682,7 @@ public class ApplicationConnection {
* Translates custom protocols in UIDL URI's to be recognizable by browser.
* All uri's from UIDL should be routed via this method before giving them
* to browser due URI's in UIDL may contain custom protocols like theme://.
- *
+ *
* @param uidlUri
* Vaadin URI from uidl
* @return translated URI ready for browser
@@ -1706,7 +1710,7 @@ public class ApplicationConnection {
/**
* Listens for Notification hide event, and redirects. Used for system
* messages, such as session expired.
- *
+ *
*/
private class NotificationRedirect implements VNotification.EventListener {
String url;
@@ -1726,9 +1730,9 @@ public class ApplicationConnection {
/**
* Data showed in tooltips are stored centrilized as it may be needed in
* varios place: caption, layouts, and in owner components themselves.
- *
+ *
* Updating TooltipInfo is done in updateComponent method.
- *
+ *
*/
public TooltipInfo getTooltipTitleInfo(Paintable titleOwner, Object key) {
if (null == titleOwner) {
@@ -1748,9 +1752,9 @@ public class ApplicationConnection {
* Component may want to delegate Tooltip handling to client. Layouts add
* Tooltip (description, errors) to caption, but some components may want
* them to appear one other elements too.
- *
+ *
* Events wanted by this handler are same as in Tooltip.TOOLTIP_EVENTS
- *
+ *
* @param event
* @param owner
*/
@@ -1763,9 +1767,9 @@ public class ApplicationConnection {
* Component may want to delegate Tooltip handling to client. Layouts add
* Tooltip (description, errors) to caption, but some components may want
* them to appear one other elements too.
- *
+ *
* Events wanted by this handler are same as in Tooltip.TOOLTIP_EVENTS
- *
+ *
* @param event
* @param owner
* @param key
@@ -1779,7 +1783,7 @@ public class ApplicationConnection {
/**
* Adds PNG-fix conditionally (only for IE6) to the specified IMG -element.
- *
+ *
* @param el
* the IMG element to fix
*/
@@ -1829,7 +1833,7 @@ public class ApplicationConnection {
* Reset the name of the current browser-window. This should reflect the
* window-name used in the server, but might be different from the
* window-object target-name on client.
- *
+ *
* @param stringAttribute
* New name for the window.
*/
@@ -1859,14 +1863,14 @@ public class ApplicationConnection {
* <p>
* This method can also be used to deregister tooltips by using null as
* tooltip
- *
+ *
* @param paintable
* Paintable "owning" this tooltip
* @param key
* key assosiated with given tooltip. Can be any object. For
* example a related dom element. Same key must be given for
* {@link #handleTooltipEvent(Event, Paintable, Object)} method.
- *
+ *
* @param tooltip
* the TooltipInfo object containing details shown in tooltip,
* null if deregistering tooltip
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java
index bfa4a653bd..89113398c9 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VView.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java
@@ -158,6 +158,18 @@ public class VView extends SimplePanel implements Container, ResizeHandler,
}
}-*/;
+ /**
+ * Returns true if the body is NOT generated, i.e if someone else has made
+ * the page that we're running in. Otherwise we're in charge of the whole
+ * page.
+ *
+ * @return true if we're running embedded
+ */
+ public boolean isEmbedded() {
+ return !getElement().getOwnerDocument().getBody().getClassName()
+ .contains(ApplicationConnection.GENERATED_BODY_CLASSNAME);
+ }
+
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
rendering = true;
@@ -184,8 +196,11 @@ public class VView extends SimplePanel implements Container, ResizeHandler,
client.setWindowName(uidl.getStringAttribute("name"));
}
- com.google.gwt.user.client.Window.setTitle(uidl
- .getStringAttribute("caption"));
+ if (!isEmbedded()) {
+ // only change window title if we're in charge of the whole page
+ com.google.gwt.user.client.Window.setTitle(uidl
+ .getStringAttribute("caption"));
+ }
// Process children
int childIndex = 0;
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
index 65b587183b..5a44a76891 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
@@ -1667,8 +1667,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
*/
protected void writeAjaxPageHtmlBodyStart(final BufferedWriter page)
throws IOException {
- page
- .write("\n</head>\n<body scroll=\"auto\" class=\"v-generated-body\">\n");
+ page.write("\n</head>\n<body scroll=\"auto\" class=\""
+ + ApplicationConnection.GENERATED_BODY_CLASSNAME + "\">\n");
}
/**
diff --git a/src/com/vaadin/ui/LoginForm.java b/src/com/vaadin/ui/LoginForm.java
index 76c567dc5e..81587f9e6a 100644
--- a/src/com/vaadin/ui/LoginForm.java
+++ b/src/com/vaadin/ui/LoginForm.java
@@ -13,6 +13,7 @@ import com.vaadin.terminal.ApplicationResource;
import com.vaadin.terminal.DownloadStream;
import com.vaadin.terminal.ParameterHandler;
import com.vaadin.terminal.URIHandler;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
/**
* LoginForm is a Vaadin component to handle common problem among Ajax
@@ -164,7 +165,9 @@ public class LoginForm extends CustomComponent {
+ "function submitOnEnter(e) { var keycode = e.keyCode || e.which;"
+ " if (keycode == 13) {document.forms[0].submit();} } \n"
+ "</script>"
- + "</head><body onload='setTarget();' style='margin:0;padding:0; background:transparent;' class=\"v-generated-body\">"
+ + "</head><body onload='setTarget();' style='margin:0;padding:0; background:transparent;' class=\""
+ + ApplicationConnection.GENERATED_BODY_CLASSNAME
+ + "\">"
+ "<div class='v-app v-app-loginpage' style=\"background:transparent;\">"
+ "<iframe name='logintarget' style='width:0;height:0;"
+ "border:0;margin:0;padding:0;'></iframe>"