Skip to content

The Unified and Autonomous Development Platform

Fix the issue that revisions in revision selector have to be clicked twice for switching in IE.

robin shine2b2682629a70
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/FormComponentInputBehavior.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/FormComponentInputBehavior.java
new file mode 100644
index 0000000000..08f211a136
--- /dev/null
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/FormComponentInputBehavior.java
@@ -0,0 +1,33 @@
+package com.pmease.commons.wicket.behavior;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.markup.html.form.FormComponent;
+
+@SuppressWarnings("serial")
+public abstract class FormComponentInputBehavior extends AjaxFormComponentUpdatingBehavior{
+
+ private String input;
+
+ public FormComponentInputBehavior() {
+ super("input");
+ }
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ FormComponent<?> component = (FormComponent<?>) getComponent();
+
+ // IE triggers "input" event when the focused on the search input even if nothing is
+ // input into search box yet. To work around this issue, we compare search string
+ // against previous value to only update the branches table if there is an actual
+ // change.
+ String newInput = component.getInput();
+ if (!ObjectUtils.equals(newInput, input)) {
+ input = newInput;
+ onInput(target);
+ }
+ }
+
+ protected abstract void onInput(AjaxRequestTarget target);
+}
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/OnTypingDoneBehavior.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/OnTypingDoneBehavior.java
index a41ff8d893..47581dc279 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/OnTypingDoneBehavior.java
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/OnTypingDoneBehavior.java
@@ -1,15 +1,20 @@
package com.pmease.commons.wicket.behavior;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
+import org.apache.wicket.markup.html.form.FormComponent;
@SuppressWarnings("serial")
public abstract class OnTypingDoneBehavior extends AjaxFormComponentUpdatingBehavior{
private int timeout;
+ private String input;
+
public OnTypingDoneBehavior(int timeout) {
super("donetyping");
this.timeout = timeout;
@@ -24,4 +29,18 @@ public abstract class OnTypingDoneBehavior extends AjaxFormComponentUpdatingBeha
response.render(OnDomReadyHeaderItem.forScript(script));
}
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ // IE triggers "input" event when the focused on the search input even if nothing is
+ // input into search box yet. To work around this issue, we compare search string
+ // against previous value to only update the branches table if there is an actual
+ // change.
+ String newInput = ((FormComponent<?>)getComponent()).getInput();
+ if (!ObjectUtils.equals(newInput, input)) {
+ input = newInput;
+ onTypingDone(target);
+ }
+ }
+
+ protected abstract void onTypingDone(AjaxRequestTarget target);
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/reposelector/RepositorySelector.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/reposelector/RepositorySelector.html
index ff1902f0fa..496659a230 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/reposelector/RepositorySelector.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/reposelector/RepositorySelector.html
@@ -16,7 +16,7 @@
</div>
<ul class="repositories list-unstyled">
<li wicket:id="repositories" class="repository selectable">
- <input wicket:id="id" type="text" class="hidden"></input><a wicket:id="link"><i class="fa fa-ext fa-repo"></i> <span wicket:id="label"></span></a>
+ <input wicket:id="id" type="text" class="hidden"/><a wicket:id="link"><i class="fa fa-ext fa-repo"></i> <span wicket:id="label"></span></a>
</li>
</ul>
</li>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/reposelector/RepositorySelector.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/reposelector/RepositorySelector.java
index 732f62a998..0ad4ddb894 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/reposelector/RepositorySelector.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/reposelector/RepositorySelector.java
@@ -13,7 +13,6 @@ import org.apache.wicket.Component;
import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.attributes.CallbackParameter;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.ComponentTag;
@@ -38,6 +37,7 @@ import org.apache.wicket.request.resource.JavaScriptResourceReference;
import com.pmease.commons.hibernate.dao.Dao;
import com.pmease.commons.wicket.assets.hotkeys.HotkeysResourceReference;
+import com.pmease.commons.wicket.behavior.FormComponentInputBehavior;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.model.Repository;
import com.pmease.gitplex.core.model.User;
@@ -97,10 +97,10 @@ public abstract class RepositorySelector extends Panel {
final TextField<String> accountSearchField = new TextField<String>("searchAccount", Model.of(""));
add(accountSearchField);
- accountSearchField.add(new AjaxFormComponentUpdatingBehavior("inputchange") {
+ accountSearchField.add(new FormComponentInputBehavior() {
@Override
- protected void onUpdate(AjaxRequestTarget target) {
+ protected void onInput(AjaxRequestTarget target) {
accountSearch = accountSearchField.getInput();
if (accountSearch != null)
accountSearch = accountSearch.trim().toLowerCase();
@@ -133,10 +133,10 @@ public abstract class RepositorySelector extends Panel {
final TextField<String> repoSearchField = new TextField<String>("searchRepo", Model.of(""));
add(repoSearchField);
- repoSearchField.add(new AjaxFormComponentUpdatingBehavior("inputchange") {
+ repoSearchField.add(new FormComponentInputBehavior() {
@Override
- protected void onUpdate(AjaxRequestTarget target) {
+ protected void onInput(AjaxRequestTarget target) {
repoSearch = repoSearchField.getInput();
if (repoSearch != null)
repoSearch = repoSearch.trim().toLowerCase();
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/RevisionSelector.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/RevisionSelector.java
index 0c9d25e569..a2b154b187 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/RevisionSelector.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/revisionselector/RevisionSelector.java
@@ -11,7 +11,6 @@ import org.apache.wicket.Component;
import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.attributes.CallbackParameter;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.ComponentTag;
@@ -40,6 +39,7 @@ import com.google.common.base.Throwables;
import com.pmease.commons.git.Git;
import com.pmease.commons.git.GitUtils;
import com.pmease.commons.wicket.assets.hotkeys.HotkeysResourceReference;
+import com.pmease.commons.wicket.behavior.FormComponentInputBehavior;
import com.pmease.commons.wicket.behavior.dropdown.DropdownBehavior;
import com.pmease.commons.wicket.behavior.dropdown.DropdownPanel;
import com.pmease.commons.wicket.component.tabbable.AjaxActionTab;
@@ -230,10 +230,10 @@ public abstract class RevisionSelector extends Panel {
};
fragment.add(keyBehavior);
- revField.add(new AjaxFormComponentUpdatingBehavior("inputchange") {
+ revField.add(new FormComponentInputBehavior() {
@Override
- protected void onUpdate(AjaxRequestTarget target) {
+ protected void onInput(AjaxRequestTarget target) {
revInput = revField.getInput();
filteredRefs.clear();
if (StringUtils.isNotBlank(revInput)) {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/repositories/AccountReposPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/repositories/AccountReposPage.java
index 25915a5d9d..e467380942 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/repositories/AccountReposPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/account/repositories/AccountReposPage.java
@@ -62,21 +62,12 @@ public class AccountReposPage extends AccountLayoutPage {
final TextField<String> searchField;
add(searchField = new ClearableTextField<String>("searchRepos", Model.of("")));
- searchField.add(new OnSearchingBehavior() {
+ searchField.add(new OnTypingDoneBehavior(100) {
@Override
- protected void onUpdate(AjaxRequestTarget target) {
- // IE triggers "input" event when the focused on the search input even if nothing is
- // input into search box yet. To work around this issue, we compare search string
- // against previous value to only update the branches table if there is an actual
- // change.
- String newSearchInput = searchField.getInput();
- if (newSearchInput != null)
- newSearchInput = newSearchInput.toLowerCase().trim();
- else
- newSearchInput = "";
- if (!newSearchInput.equals(searchInput))
- super.onUpdate(target);
+ protected void onTypingDone(AjaxRequestTarget target) {
+ target.add(reposContainer);
+ target.add(pagingNavigator);
}
});
@@ -216,17 +207,4 @@ public class AccountReposPage extends AccountLayoutPage {
response.render(CssHeaderItem.forReference(new CssResourceReference(AccountReposPage.class, "account-repos.css")));
}
- private class OnSearchingBehavior extends OnTypingDoneBehavior {
-
- public OnSearchingBehavior() {
- super(100);
- }
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- target.add(reposContainer);
- target.add(pagingNavigator);
- }
-
- }
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/home/accounts/AccountsPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/home/accounts/AccountsPage.java
index 0546547c82..82dc72306f 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/home/accounts/AccountsPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/home/accounts/AccountsPage.java
@@ -5,7 +5,6 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
-import org.apache.commons.lang3.ObjectUtils;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
@@ -64,23 +63,14 @@ public class AccountsPage extends LayoutPage {
super.onInitialize();
add(searchInput = new ClearableTextField<String>("searchAccounts", Model.of("")));
- searchInput.add(new OnSearchingBehavior() {
+ searchInput.add(new OnTypingDoneBehavior(100) {
@Override
- protected void onUpdate(AjaxRequestTarget target) {
- // IE triggers "input" event when the focused on the search input even if nothing is
- // input into search box yet. To work around this issue, we compare search string
- // against previous value to only update the branches table if there is an actual
- // change.
- String newSearchFor = searchInput.getInput();
- if (StringUtils.isNotBlank(newSearchFor))
- newSearchFor = newSearchFor.trim().toLowerCase();
- else
- newSearchFor = null;
- if (!ObjectUtils.equals(newSearchFor, searchFor))
- super.onUpdate(target);
+ protected void onTypingDone(AjaxRequestTarget target) {
+ target.add(accountsContainer);
+ target.add(pagingNavigator);
}
-
+
});
add(new Link<Void>("addNew") {
@@ -240,17 +230,4 @@ public class AccountsPage extends LayoutPage {
response.render(CssHeaderItem.forReference(new CssResourceReference(AccountsPage.class, "accounts.css")));
}
- private class OnSearchingBehavior extends OnTypingDoneBehavior {
-
- public OnSearchingBehavior() {
- super(100);
- }
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- target.add(accountsContainer);
- target.add(pagingNavigator);
- }
-
- }
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/branches/RepoBranchesPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/branches/RepoBranchesPage.java
index e028b1aba4..ff671b5f46 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/branches/RepoBranchesPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/branches/RepoBranchesPage.java
@@ -9,7 +9,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
-import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.validator.routines.PercentValidator;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -231,24 +230,7 @@ public class RepoBranchesPage extends RepositoryPage {
}));
add(searchInput = new ClearableTextField<String>("searchBranches", Model.of("")));
- searchInput.add(new OnSearchingBehavior() {
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- // IE triggers "input" event when the focused on the search input even if nothing is
- // input into search box yet. To work around this issue, we compare search string
- // against previous value to only update the branches table if there is an actual
- // change.
- String newSearchFor = searchInput.getInput();
- if (StringUtils.isNotBlank(newSearchFor))
- newSearchFor = newSearchFor.trim().toLowerCase();
- else
- newSearchFor = null;
- if (!ObjectUtils.equals(newSearchFor, searchFor))
- super.onUpdate(target);
- }
-
- });
+ searchInput.add(new OnSearchingBehavior());
branchesContainer = new WebMarkupContainer("branchesContainer");
branchesContainer.setOutputMarkupId(true);
@@ -571,7 +553,7 @@ public class RepoBranchesPage extends RepositoryPage {
}
@Override
- protected void onUpdate(AjaxRequestTarget target) {
+ protected void onTypingDone(AjaxRequestTarget target) {
target.add(branchesContainer);
target.add(pagingNavigator);
}