From dd630f8aebde8c3138dc0d55ebf4a16d0db806b7 Mon Sep 17 00:00:00 2001 From: James Moger Date: Tue, 30 Oct 2012 17:04:47 -0400 Subject: [PATCH] Fix intermittent Wicket page expirations on EditNNN pages --- .../wicket/pages/EditRepositoryPage.java | 5 +++++ src/com/gitblit/wicket/pages/EditTeamPage.java | 5 +++++ src/com/gitblit/wicket/pages/EditUserPage.java | 5 +++++ src/com/gitblit/wicket/pages/RootSubPage.java | 18 ++++++++++++++++++ 4 files changed, 33 insertions(+) diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java index f791cf60..cc0db680 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -115,6 +115,11 @@ public class EditRepositoryPage extends RootSubPage { setStatelessHint(false); setOutputMarkupId(true); } + + @Override + protected boolean requiresPageMap() { + return true; + } protected void setupPage(RepositoryModel model) { this.repositoryModel = model; diff --git a/src/com/gitblit/wicket/pages/EditTeamPage.java b/src/com/gitblit/wicket/pages/EditTeamPage.java index 8ced03c2..a22361f1 100644 --- a/src/com/gitblit/wicket/pages/EditTeamPage.java +++ b/src/com/gitblit/wicket/pages/EditTeamPage.java @@ -75,6 +75,11 @@ public class EditTeamPage extends RootSubPage { setOutputMarkupId(true); } + @Override + protected boolean requiresPageMap() { + return true; + } + protected void setupPage(final TeamModel teamModel) { if (isCreate) { super.setupPage(getString("gb.newTeam"), ""); diff --git a/src/com/gitblit/wicket/pages/EditUserPage.java b/src/com/gitblit/wicket/pages/EditUserPage.java index 19d297b1..7942d6fa 100644 --- a/src/com/gitblit/wicket/pages/EditUserPage.java +++ b/src/com/gitblit/wicket/pages/EditUserPage.java @@ -76,6 +76,11 @@ public class EditUserPage extends RootSubPage { setStatelessHint(false); setOutputMarkupId(true); } + + @Override + protected boolean requiresPageMap() { + return true; + } protected void setupPage(final UserModel userModel) { if (isCreate) { diff --git a/src/com/gitblit/wicket/pages/RootSubPage.java b/src/com/gitblit/wicket/pages/RootSubPage.java index 891c892a..e7e12ccc 100644 --- a/src/com/gitblit/wicket/pages/RootSubPage.java +++ b/src/com/gitblit/wicket/pages/RootSubPage.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.wicket.PageParameters; +import org.apache.wicket.Session; import org.apache.wicket.markup.html.basic.Label; import com.gitblit.Constants.AccessRestrictionType; @@ -38,10 +39,27 @@ public abstract class RootSubPage extends RootPage { public RootSubPage() { super(); + createPageMapIfNeeded(); } public RootSubPage(PageParameters params) { super(params); + createPageMapIfNeeded(); + } + + protected boolean requiresPageMap() { + return false; + } + + protected void createPageMapIfNeeded() { + if (requiresPageMap()) { + // because Gitblit strives for page-statelessness + // Wicket seems to get confused as to when it really should + // generate a page map for complex pages. Conditionally ensure we + // have a page map for complex AJAX pages like the EditNNN pages. + Session.get().pageMapForName(null, true); + setVersioned(true); + } } @Override -- 2.39.5