import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import com.vaadin.annotations.RootInitRequiresBrowserDetails;
+import com.vaadin.annotations.EagerInit;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Widgetset;
import com.vaadin.data.util.converter.Converter;
if (!initedRoots.contains(rootId)) {
boolean initRequiresBrowserDetails = preserveRoot
- || root.getClass().isAnnotationPresent(
- RootInitRequiresBrowserDetails.class);
+ || !root.getClass()
+ .isAnnotationPresent(EagerInit.class);
if (initRequiresBrowserDetails && browserDetails == null) {
pendingRoots.put(rootId, new PendingRootRequest(request));
} else {
--- /dev/null
+package com.vaadin.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.ui.Root;
+
+/**
+ * Indicates that the init method in a Root class can be called before full
+ * browser details ({@link WrappedRequest#getBrowserDetails()}) are available.
+ * This will make the UI appear more quickly, as ensuring the availability of
+ * this information typically requires an additional round trip to the client.
+ *
+ * @see Root#init(com.vaadin.terminal.WrappedRequest)
+ * @see WrappedRequest#getBrowserDetails()
+ *
+ * @since 7.0
+ *
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface EagerInit {
+ // No values
+}
+++ /dev/null
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import com.vaadin.terminal.WrappedRequest;
-import com.vaadin.ui.Root;
-
-/**
- * Indicates that the init method in a Root class should not be called until
- * full browser details ({@link WrappedRequest#getBrowserDetails()}) are
- * available. Ensuring the availability of this information will typically
- * requires an additional round trip to the client, which will cause the
- * application startup to progress more slowly.
- *
- * @see Root#init(com.vaadin.terminal.WrappedRequest)
- * @see WrappedRequest#getBrowserDetails()
- *
- * @since 7.0
- *
- */
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface RootInitRequiresBrowserDetails {
- // No methods
-}
import com.vaadin.Application;
import com.vaadin.RootRequiresMoreInformationException;
-import com.vaadin.annotations.RootInitRequiresBrowserDetails;
+import com.vaadin.annotations.EagerInit;
import com.vaadin.terminal.gwt.server.WebBrowser;
import com.vaadin.ui.Root;
* This information is only guaranteed to be available in some special
* cases, for instance when {@link Application#getRoot} is called again
* after throwing {@link RootRequiresMoreInformationException} or in
- * {@link Root#init(WrappedRequest)} if the Root class is annotated with
- * {@link RootInitRequiresBrowserDetails}
+ * {@link Root#init(WrappedRequest)} for a Root class not annotated with
+ * {@link EagerInit}
*
* @return the browser details, or <code>null</code> if details are not
* available
import java.util.Map;
import com.vaadin.Application;
-import com.vaadin.annotations.RootInitRequiresBrowserDetails;
+import com.vaadin.annotations.EagerInit;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
import com.vaadin.event.ActionManager;
* {@link #setContent(ComponentContainer)}.
* </p>
* <p>
- * If a {@link RootInitRequiresBrowserDetails} annotation is present on a class
- * extending <code>Root</code>, the framework will ensure {@link BrowserDetails}
- * are present in the {@link WrappedRequest} passed to the init method.
+ * If a {@link EagerInit} annotation is present on a class extending
+ * <code>Root</code>, the framework will use a faster initialization method
+ * which will not ensure that {@link BrowserDetails} are present in the
+ * {@link WrappedRequest} passed to the init method.
* </p>
*
* @see #init(WrappedRequest)
* Helper class to emulate the main window from Vaadin 6 using roots. This
* class should be used in the same way as Window used as a browser level
* window in Vaadin 6 together with {@Application.LegacyApplication
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
* }
*/
@Deprecated
* <p>
* The {@link WrappedRequest} can be used to get information about the
* request that caused this root to be created. By default, the
- * {@link BrowserDetails} are note guaranteed to be available in the
- * request. Availability of the browser details can be requested by adding
- * the {@link RootInitRequiresBrowserDetails} annotation to the class.
+ * {@link BrowserDetails} will be available in the request. If the browser
+ * details are not required, loading the application in the browser can take
+ * some shortcuts giving a faster initial rendering. This can be indicated
+ * by adding the {@link EagerInit} annotation to the Root class.
* </p>
*
* @param request
package com.vaadin.tests.application;
-import com.vaadin.annotations.RootInitRequiresBrowserDetails;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.tests.components.AbstractTestApplication;
import com.vaadin.ui.Label;
import com.vaadin.ui.Root;
public class RefreshStatePreserve extends AbstractTestApplication {
- @RootInitRequiresBrowserDetails
public static class RefreshStateRoot extends Root {
@Override
public void init(WrappedRequest request) {
package com.vaadin.tests.components.root;
import com.vaadin.RootRequiresMoreInformationException;
-import com.vaadin.annotations.RootInitRequiresBrowserDetails;
+import com.vaadin.annotations.EagerInit;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.terminal.WrappedRequest.BrowserDetails;
public class LazyInitRoots extends AbstractTestApplication {
- @RootInitRequiresBrowserDetails
- private static class LazyInitRoot extends Root {
+ @EagerInit
+ private static class EagerInitRoot extends Root {
@Override
public void init(WrappedRequest request) {
BrowserDetails browserDetails = request.getBrowserDetails();
getContent().addComponent(
- new Label("Lazy init root: "
- + browserDetails.getUriFragment()));
+ new Label("Lazy init root: " + browserDetails));
}
}
};
return root;
}
- } else if (request.getParameter("lazyInit") != null) {
+ } else if (request.getParameter("eagerInit") != null) {
// Root inited on second request
- return new LazyInitRoot();
+ return new EagerInitRoot();
} else {
// The standard root
Root root = new Root() {
lazyCreateLink.setTargetName("_blank");
addComponent(lazyCreateLink);
- Link lazyInitLink = new Link("Open lazyInit root",
+ Link lazyInitLink = new Link("Open eagerInit root",
new ExternalResource(getURL()
- + "?lazyInit#lazyInit"));
+ + "?eagerInit#eagerInit"));
lazyInitLink.setTargetName("_blank");
addComponent(lazyInitLink);
}
package com.vaadin.tests.components.root;
-import com.vaadin.annotations.RootInitRequiresBrowserDetails;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.tests.components.AbstractTestRoot;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
-@RootInitRequiresBrowserDetails
public class UriFragmentTest extends AbstractTestRoot {
private final Label fragmentLabel = new Label();