MyFaces Core
  1. MyFaces Core
  2. MYFACES-3653

Partial update for input elements require special case

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      any browser

      Description

      When focus is own by an input element and an incoming partial update will update the element, the focus is removed from the element. Most often this occurs when validation is run for each input field and input is cleared if corresponding validation failed.

      1. ICE-8367.patch
        10 kB
        Mircea Toma

        Activity

        Hide
        Mircea Toma added a comment -

        This issue was first handled by http://jira.icesoft.org/browse/ICE-4776 and then ported in Mojarra's code base, see http://java.net/jira/browse/JAVASERVERFACES-1222 .
        Later on improvements were made, described here http://java.net/jira/browse/JAVASERVERFACES-2461 and http://java.net/jira/browse/JAVASERVERFACES-2578 .

        Show
        Mircea Toma added a comment - This issue was first handled by http://jira.icesoft.org/browse/ICE-4776 and then ported in Mojarra's code base, see http://java.net/jira/browse/JAVASERVERFACES-1222 . Later on improvements were made, described here http://java.net/jira/browse/JAVASERVERFACES-2461 and http://java.net/jira/browse/JAVASERVERFACES-2578 .
        Hide
        Mircea Toma added a comment -

        Attached patch for Myfaces.

        Show
        Mircea Toma added a comment - Attached patch for Myfaces.
        Hide
        Werner Punz added a comment -

        Wow, thanks for the excellent patch, I will apply it tomorrow.

        Show
        Werner Punz added a comment - Wow, thanks for the excellent patch, I will apply it tomorrow.
        Hide
        Werner Punz added a comment -

        Ok the patch is applied, I however have one gripe with it, it only works if you update the input element itself, there is at least a way for some browsers to set the focus back after an update
        (most newer browsers and IE and Firefox) I will work that in as well.

        Show
        Werner Punz added a comment - Ok the patch is applied, I however have one gripe with it, it only works if you update the input element itself, there is at least a way for some browsers to set the focus back after an update (most newer browsers and IE and Firefox) I will work that in as well.
        Hide
        Werner Punz added a comment -

        Ok I also now added some fallback code for the universal case, which keeps the focus and caret position in place. The question arises now, why doing the copy properties method at all, the universal fallback code seems to work sufficiently for me for all modern browsers (and old ies down to ie7 quirks mode == ie6)
        Mircea can you shed a light on this why you went that route instead of simply using document.activeElement and trying to retain the caret position? Maybe I have overlooked something.
        For now I will keep both cases in the codebase, but I need further input on the patch why you went with copyproperties and retaining the old element.

        Show
        Werner Punz added a comment - Ok I also now added some fallback code for the universal case, which keeps the focus and caret position in place. The question arises now, why doing the copy properties method at all, the universal fallback code seems to work sufficiently for me for all modern browsers (and old ies down to ie7 quirks mode == ie6) Mircea can you shed a light on this why you went that route instead of simply using document.activeElement and trying to retain the caret position? Maybe I have overlooked something. For now I will keep both cases in the codebase, but I need further input on the patch why you went with copyproperties and retaining the old element.
        Hide
        Werner Punz added a comment -

        Resolved until I get further input on it

        Show
        Werner Punz added a comment - Resolved until I get further input on it
        Hide
        Mircea Toma added a comment -

        Werner, you are right the newer browsers should work fine when keeping track of the focused element with document.activeElement. There are cases thought were the JS application code can interfere with the re-applying of the focus saved from document.activeElement, and this can occur in a nondeterministic way.

        I agree that it is a lot of code for such a basic feature but it can cover a large percentage of focus related issues that an application can have, even with document.activeElement mechanism in place.

        Show
        Mircea Toma added a comment - Werner, you are right the newer browsers should work fine when keeping track of the focused element with document.activeElement. There are cases thought were the JS application code can interfere with the re-applying of the focus saved from document.activeElement, and this can occur in a nondeterministic way. I agree that it is a lot of code for such a basic feature but it can cover a large percentage of focus related issues that an application can have, even with document.activeElement mechanism in place.
        Hide
        Werner Punz added a comment -

        Ok thanks for the clarification, I now can see our point, I will then leave your code active and will make my global solution optional via config param so that users can switch it on on the fly. I think this makes most sense.

        Show
        Werner Punz added a comment - Ok thanks for the clarification, I now can see our point, I will then leave your code active and will make my global solution optional via config param so that users can switch it on on the fly. I think this makes most sense.
        Hide
        Werner Punz added a comment -

        reopened my focus fix needs to be set as optional param.

        Show
        Werner Punz added a comment - reopened my focus fix needs to be set as optional param.
        Hide
        Werner Punz added a comment -

        Added now the icefaces solution as always enabled and my own as optional config param (preserveFocus) blogpost will follow to document this.

        Show
        Werner Punz added a comment - Added now the icefaces solution as always enabled and my own as optional config param (preserveFocus) blogpost will follow to document this.

          People

          • Assignee:
            Werner Punz
            Reporter:
            Mircea Toma
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development