[ 
https://issues.apache.org/jira/browse/TOBAGO-961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12978231#action_12978231
 ] 

Helmut Swaczinna commented on TOBAGO-961:
-----------------------------------------

I solved the problem. Apply this changes to tobago.js:


  capturedFocusId: null,
  
  captureFocus: function() {
    if (document.activeElement) {
      Tobago.capturedFocusId = document.activeElement.id;
    }
  },
  
  restoreFocus: function() {
    if (Tobago.capturedFocusId != null) {
      var focusedElement = document.getElementById(Tobago.capturedFocusId); 
      if (focusedElement != null) {
        focusedElement.focus();
        if (focusedElement.select) {
          focusedElement.select();
        }
      }
      Tobago.capturedFocusId = null;
    } 
  },

  reloadComponent2: function(source, id, actionId, options) {
    var reloadOptions = {
      onSuccess:  Tobago.captureFocus, 
      onComplete: Tobago.restoreFocus
    };
    if (options) {
      reloadOptions = Tobago.extend(reloadOptions, options);
    }
    var container = this.ajaxComponents[id];
    if (container) {
      if (typeof container == "string") {
        if (!actionId) {
          actionId = container;
        }
        container = this.element(container);
        Tobago.Updater.update2(source, container, this.page, actionId, id, 
reloadOptions);
      } else if ((typeof container == "object") && container.tagName) {
        if (!actionId) {
          actionId = container.id;
        }
        Tobago.Updater.update2(source, container, this.page, actionId, id, 
reloadOptions);
      } else if ((typeof container == "object") && (typeof 
container.reloadWithAction2 == "function")) {
        if (!actionId) {
          if (container.id) {
            actionId = container.id;
          } else {
            actionId = "_tbg_no_action_";
          }
        }
        container.reloadWithAction2(source, actionId, reloadOptions);
      } else {
        LOG.warn("Illegal container for reload:" + (typeof container));
      }
    } else {
      LOG.warn("Cannot find container for '" + id + "'! Skipping reload!");
      LOG.debugAjaxComponents();
    }
  },



> Focus is lost after ajax reload
> -------------------------------
>
>                 Key: TOBAGO-961
>                 URL: https://issues.apache.org/jira/browse/TOBAGO-961
>             Project: MyFaces Tobago
>          Issue Type: Improvement
>          Components: Themes
>    Affects Versions: 1.0.33
>         Environment: All
>            Reporter: Helmut Swaczinna
>
> When the component which owns the keyboard focus is on the reloaded part of 
> the page, the focus is lost after ajax reload.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to