Skip to content

The Unified and Autonomous Development Platform

Intercept Wicket.Ajax.Call.prototype.success to adjust dropdown position at appropriate time if dropdown size is changed due to ajax component replace.

robinf1197cce39eb
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/AbstractWicketConfig.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/AbstractWicketConfig.java
index bfa45c33bf..5afac9b698 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/AbstractWicketConfig.java
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/AbstractWicketConfig.java
@@ -1,14 +1,6 @@
package com.pmease.commons.wicket;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.wicket.Component;
import org.apache.wicket.RuntimeConfigurationType;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.AjaxRequestTarget.IJavaScriptResponse;
import org.apache.wicket.protocol.http.WebApplication;
import com.google.inject.Singleton;
@@ -33,21 +25,6 @@ public abstract class AbstractWicketConfig extends WebApplication {
getMarkupSettings().setStripWicketTags(true);
getRequestCycleSettings().setGatherExtendedBrowserInfo(true);
- getAjaxRequestTargetListeners().add(new AjaxRequestTarget.IListener() {
-
- @Override
- public void onBeforeRespond(Map<String, Component> map, AjaxRequestTarget target) {
-
- }
-
- @Override
- public void onAfterRespond(Map<String, Component> map, IJavaScriptResponse response) {
- List<String> quotedIds = new ArrayList<String>();
- for (String id: map.keySet())
- quotedIds.add("\"" + id + "\"");
- response.addJavaScript("wicketAjaxCompleted([" + StringUtils.join(quotedIds, ",") + "]);");
- }
- });
}
}
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/javascript/common.js b/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/javascript/common.js
index f9ddbcd7ec..e69de29bb2 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/javascript/common.js
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/asset/javascript/common.js
@@ -1,3 +0,0 @@
-function wicketAjaxCompleted(replacedElementIds) {
- $("body>.dropdown:visible:last").align();
-}
\ No newline at end of file
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/dropdown/dropdown.js b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/dropdown/dropdown.js
index d837d1b80b..72a3477d1c 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/dropdown/dropdown.js
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/dropdown/dropdown.js
@@ -111,6 +111,7 @@ function showDropdown(trigger, dropdown, alignment, dropdownLoader) {
}
function dropdownLoaded(dropdownId) {
+ //$("#" + dropdownId).align();
}
function hideDropdown(dropdownId) {
@@ -150,3 +151,16 @@ $(document).click(function(event) {
hideDropdown(childDropdownEl.id);
}
});
+
+$(function() {
+ Wicket.Ajax.Call.prototype.dropdownSuccess = Wicket.Ajax.Call.prototype.success;
+ Wicket.Ajax.Call.prototype.success = function(steps, attrs) {
+ steps.push(function (notify) {
+ $("body>.dropdown:visible:last").align();
+ notify();
+ });
+ this.dropdownSuccess(steps, attrs);
+ };
+
+});
+