From ed295f8a491895081f4d20c0f2397aedd7ce16f6 Mon Sep 17 00:00:00 2001 From: James Moger Date: Fri, 23 Mar 2012 16:31:22 -0400 Subject: [PATCH] Updated login and search forms to use the SessionlessForm --- .../gitblit/wicket/pages/LuceneSearchPage.java | 4 ++-- src/com/gitblit/wicket/pages/RepositoryPage.java | 6 +++--- src/com/gitblit/wicket/pages/RootPage.java | 16 ++++++++++++---- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/com/gitblit/wicket/pages/LuceneSearchPage.java b/src/com/gitblit/wicket/pages/LuceneSearchPage.java index c9e70661..997ef213 100644 --- a/src/com/gitblit/wicket/pages/LuceneSearchPage.java +++ b/src/com/gitblit/wicket/pages/LuceneSearchPage.java @@ -23,7 +23,6 @@ import org.apache.wicket.Component; import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.ListMultipleChoice; -import org.apache.wicket.markup.html.form.StatelessForm; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.panel.Fragment; import org.apache.wicket.markup.repeater.Item; @@ -41,6 +40,7 @@ import com.gitblit.models.UserModel; import com.gitblit.utils.ArrayUtils; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.GitBlitWebSession; +import com.gitblit.wicket.SessionlessForm; import com.gitblit.wicket.StringChoiceRenderer; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.LinkPanel; @@ -121,7 +121,7 @@ public class LuceneSearchPage extends RootPage { // search form final Model queryModel = new Model(query); final Model> repositoriesModel = new Model>(searchRepositories); - StatelessForm form = new StatelessForm("searchForm") { + SessionlessForm form = new SessionlessForm("searchForm", getClass()) { private static final long serialVersionUID = 1L; diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.java b/src/com/gitblit/wicket/pages/RepositoryPage.java index cd3c8a2e..132b1f7f 100644 --- a/src/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/com/gitblit/wicket/pages/RepositoryPage.java @@ -27,7 +27,6 @@ import org.apache.wicket.Component; import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.markup.html.form.StatelessForm; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.link.ExternalLink; import org.apache.wicket.markup.html.panel.Fragment; @@ -51,6 +50,7 @@ import com.gitblit.utils.TicgitUtils; import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.PageRegistration; import com.gitblit.wicket.PageRegistration.OtherPageLink; +import com.gitblit.wicket.SessionlessForm; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.LinkPanel; import com.gitblit.wicket.panels.NavigationPanel; @@ -314,7 +314,7 @@ public abstract class RepositoryPage extends BasePage { return WicketUtils.newObjectParameter(repositoryName, commitId); } - private static class SearchForm extends StatelessForm implements Serializable { + private class SearchForm extends SessionlessForm implements Serializable { private static final long serialVersionUID = 1L; private final String repositoryName; @@ -325,7 +325,7 @@ public abstract class RepositoryPage extends BasePage { Constants.SearchType.COMMIT); public SearchForm(String id, String repositoryName) { - super(id); + super(id, RepositoryPage.this.getClass(), RepositoryPage.this.getPageParameters()); this.repositoryName = repositoryName; DropDownChoice searchType = new DropDownChoice( "searchType", Arrays.asList(Constants.SearchType.values())); diff --git a/src/com/gitblit/wicket/pages/RootPage.java b/src/com/gitblit/wicket/pages/RootPage.java index bf811f94..57678dfb 100644 --- a/src/com/gitblit/wicket/pages/RootPage.java +++ b/src/com/gitblit/wicket/pages/RootPage.java @@ -32,7 +32,6 @@ import java.util.regex.Pattern; import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.form.PasswordTextField; -import org.apache.wicket.markup.html.form.StatelessForm; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; @@ -48,6 +47,7 @@ import com.gitblit.utils.StringUtils; import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.PageRegistration; import com.gitblit.wicket.PageRegistration.DropDownMenuItem; +import com.gitblit.wicket.SessionlessForm; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.NavigationPanel; @@ -117,7 +117,7 @@ public abstract class RootPage extends BasePage { add(navPanel); // login form - StatelessForm loginForm = new StatelessForm("loginForm") { + SessionlessForm loginForm = new SessionlessForm("loginForm", getClass(), getPageParameters()) { private static final long serialVersionUID = 1L; @@ -208,8 +208,16 @@ public abstract class RootPage extends BasePage { } if (!continueToOriginalDestination()) { - // Redirect to home page - setResponsePage(getApplication().getHomePage()); + PageParameters params = getPageParameters(); + if (params == null) { + // redirect to this page + setResponsePage(getClass()); + } else { + // Strip username and password and redirect to this page + params.remove("username"); + params.remove("password"); + setResponsePage(getClass(), params); + } } } } -- 2.39.5