* the initialization request
* @param uiId
* the id of the new ui
+ * @param embedId
+ * the embed id of this UI, or <code>null</code> if no id is
+ * known
+ *
+ * @see #getUIId()
+ * @see #getEmbedId()
*/
- public void doInit(VaadinRequest request, int uiId) {
+ public void doInit(VaadinRequest request, int uiId, String embedId) {
if (this.uiId != -1) {
- throw new IllegalStateException("UI id has already been defined");
+ String message = "This UI instance is already initialized (as UI id "
+ + this.uiId
+ + ") and can therefore not be initialized again (as UI id "
+ + uiId + "). ";
+
+ if (getSession() != null
+ && !getSession().equals(VaadinSession.getCurrent())) {
+ message += "Furthermore, it is already attached to another VaadinSession. ";
+ }
+ message += "Please make sure you are not accidentally reusing an old UI instance.";
+
+ throw new IllegalStateException(message);
}
this.uiId = uiId;
+ this.embedId = embedId;
// Actual theme - used for finding CustomLayout templates
theme = request.getParameter("theme");