diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-09-24 16:01:35 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-09-24 16:01:47 +0300 |
commit | 94dd167211592e3a21ef80addb88fe00967a36c8 (patch) | |
tree | 401c7a2425f4cabc4a72337f459e43172cf93dde /server/src/com | |
parent | ded204acce46a009bac6d6562de43d5b6120e349 (diff) | |
download | vaadin-framework-94dd167211592e3a21ef80addb88fe00967a36c8.tar.gz vaadin-framework-94dd167211592e3a21ef80addb88fe00967a36c8.zip |
Add UI id to UICreateEvent for use in createInstance (#9721)
Diffstat (limited to 'server/src/com')
-rw-r--r-- | server/src/com/vaadin/server/AbstractCommunicationManager.java | 5 | ||||
-rw-r--r-- | server/src/com/vaadin/server/UICreateEvent.java | 35 |
2 files changed, 37 insertions, 3 deletions
diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java index ed3b73dc20..b5237438ba 100644 --- a/server/src/com/vaadin/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java @@ -2525,9 +2525,11 @@ public abstract class AbstractCommunicationManager implements Serializable { // No existing UI found - go on by creating and initializing one + Integer uiId = Integer.valueOf(session.getNextUIid()); + // Explicit Class.cast to detect if the UIProvider does something // unexpected - UICreateEvent event = new UICreateEvent(request, uiClass); + UICreateEvent event = new UICreateEvent(request, uiClass, uiId); UI ui = uiClass.cast(provider.createInstance(event)); // Initialize some fields for a newly created UI @@ -2535,7 +2537,6 @@ public abstract class AbstractCommunicationManager implements Serializable { // Session already set for LegacyWindow ui.setSession(session); } - Integer uiId = Integer.valueOf(session.getNextUIid()); // Set thread local here so it is available in init UI.setCurrent(ui); diff --git a/server/src/com/vaadin/server/UICreateEvent.java b/server/src/com/vaadin/server/UICreateEvent.java index 561bc4cdfa..a608b5eb19 100644 --- a/server/src/com/vaadin/server/UICreateEvent.java +++ b/server/src/com/vaadin/server/UICreateEvent.java @@ -28,9 +28,11 @@ import com.vaadin.ui.UI; public class UICreateEvent extends UIProviderEvent { private final Class<? extends UI> uiClass; + private final Integer uiId; /** - * Creates a new UI create event for a given VaadinRequest and UI class. + * Creates a new UI create event for a given VaadinRequest and UI class but + * without a UI id. * * @param request * the request for which the UI will be created @@ -38,8 +40,26 @@ public class UICreateEvent extends UIProviderEvent { * the UI class that will be created */ public UICreateEvent(VaadinRequest request, Class<? extends UI> uiClass) { + this(request, uiClass, null); + } + + /** + * Creates a new UI create event for a given VaadinRequest, UI class and UI + * id + * + * @param request + * the request for which the UI will be created + * @param uiClass + * the UI class that will be created + * @param uiId + * the id reserved for the UI; or <code>null</code> if no id has + * yet been allocated. + */ + public UICreateEvent(VaadinRequest request, Class<? extends UI> uiClass, + Integer uiId) { super(request); this.uiClass = uiClass; + this.uiId = uiId; } /** @@ -51,4 +71,17 @@ public class UICreateEvent extends UIProviderEvent { return uiClass; } + /** + * Gets the id of the UI about to be created. This might be + * <code>null</code> if the id has not yet been determined. + * <p> + * The UI id is generally only available in + * {@link UIProvider#createInstance(UICreateEvent)} + * + * @return the UI id; or <code>null</code> if the UI id is not yet known. + */ + public Integer getUiId() { + return uiId; + } + } |