You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2016/07/19 21:32:38 UTC
wicket git commit: WICKET-6209 move try-catch into function which is
invoked via #setTimeout(), so IE errors get caught
Repository: wicket
Updated Branches:
refs/heads/master 7401712f8 -> 7fe591fa3
WICKET-6209 move try-catch into function which is invoked via #setTimeout(), so IE errors get caught
;removed workaround for WicketWICKET-5755, i.e. directly call #requestFocus() since it now always uses #setTimeout() to request focus (see WICKET-5858)
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/7fe591fa
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/7fe591fa
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/7fe591fa
Branch: refs/heads/master
Commit: 7fe591fa301f4e7da65141643c428ea9a3f01aa6
Parents: 7401712
Author: Sven Meier <sv...@apache.org>
Authored: Tue Jul 19 22:47:15 2016 +0200
Committer: Sven Meier <sv...@apache.org>
Committed: Tue Jul 19 23:04:42 2016 +0200
----------------------------------------------------------------------
.../wicket/ajax/res/js/wicket-ajax-jquery.js | 47 +++++++++-----------
1 file changed, 22 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/7fe591fa/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
index a7aa0d9..f0c5c12 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
@@ -1098,13 +1098,7 @@
this._executeHandlers(attrs.sh, attrs, null, null, 'success');
Wicket.Event.publish(Wicket.Event.Topic.AJAX_CALL_SUCCESS, attrs, null, null, 'success');
- // set the focus to the last component
- if (Wicket.Browser.isIELessThan9()) {
- // WICKET-5755
- window.setTimeout("Wicket.Focus.requestFocus();", 0);
- } else {
- Wicket.Focus.requestFocus();
- }
+ Wicket.Focus.requestFocus();
// continue to next step (which should make the processing stop, as success should be the final step)
return FunctionsExecuter.DONE;
@@ -2702,30 +2696,33 @@
if (toFocus) {
Wicket.Log.info("Calling focus on " + WF.lastFocusId);
- try {
- if (WF.focusSetFromServer) {
- // WICKET-5858
- window.setTimeout(function () { toFocus.focus(); }, 0);
- } else {
- // avoid loops like - onfocus triggering an event the modifies the tag => refocus => the event is triggered again
- var temp = toFocus.onfocus;
- toFocus.onfocus = null;
-
- // IE needs setTimeout (it seems not to call onfocus sync. when focus() is called
- window.setTimeout(function () {toFocus.focus(); toFocus.onfocus = temp; }, 0);
+
+ var safeFocus = function() {
+ try {
+ toFocus.focus();
+ } catch (ignore) {
+ // WICKET-6209 IE fails if toFocus is disabled
}
- } catch (ignore) {
+ };
+
+ if (WF.focusSetFromServer) {
+ // WICKET-5858
+ window.setTimeout(safeFocus, 0);
+ } else {
+ // avoid loops like - onfocus triggering an event the modifies the tag => refocus => the event is triggered again
+ var temp = toFocus.onfocus;
+ toFocus.onfocus = null;
+
+ // IE needs setTimeout (it seems not to call onfocus sync. when focus() is called
+ window.setTimeout(function () { safeFocus(); toFocus.onfocus = temp; }, 0);
}
- }
- else {
+ } else {
WF.lastFocusId = "";
Wicket.Log.info("Couldn't set focus on element with id '" + WF.lastFocusId + "' because it is not in the page anymore");
}
- }
- else if (WF.refocusLastFocusedComponentAfterResponse) {
+ } else if (WF.refocusLastFocusedComponentAfterResponse) {
Wicket.Log.info("last focus id was not set");
- }
- else {
+ } else {
Wicket.Log.info("refocus last focused component not needed/allowed");
}
Wicket.Focus.refocusLastFocusedComponentAfterResponse = false;