ICEfaces
  1. ICEfaces
  2. ICE-8449

icecore:singleSubmit functioning inconsistently with some h:selectMany components

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: EE-3.0.0.GA, 3.1
    • Fix Version/s: 3.2
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      icefaces3 trunk revision# 30410
      icefaces-3.0.x-maintenance revision# 30398
      Firefox14, Chrome21, IE9

      Description

      When the icecore:singleSubmit tag is present and trying to select more than one item from a h:selectManyMenu or h:selectManyListbox, a submit will not always occur. A submit does occur consistently for an h:selectManyCheckbox component.

      Test containing an h:selectManyListbox component is located here: http://server.ice:8888/svn/repo/qa/trunk/Regression-Icefaces2/Manual/singleSubmit

        Activity

        Hide
        Ted Goddard added a comment -

        Feel free to assign this back to me if there's no emergency, but I will not be able to look at it until September.

        Show
        Ted Goddard added a comment - Feel free to assign this back to me if there's no emergency, but I will not be able to look at it until September.
        Hide
        Deryk Sinotte added a comment - - edited

        Kind of an interesting behaviour. When you click on a single entry going up or down the list, the component works fine. When you click on a single entry and then command click on another entry to select multiple values, the behaviour depends on whether or not you are going up or down. If you select the next item from below the first item, it fails. If you select an item above the first item it works.
        The issue is in the logic for the enableSingleSubmit code:
        if (0 == elementType.indexOf("select-")) {
        if (element.selectedIndex == element.previousSelectedIndex)

        { return; }

        else

        { element.previousSelectedIndex = element.selectedIndex; }

        }
        It checks to see if this is a "select-" element (which it is, checkboxes are "input" types so aren't affected by this logic). Next it checks to see if the selectedIndex is different from the previously selected index. If it is, it all works. If they are the same, it simply returns and no submit is done. If you watch those values in the client console.
        When it fails:
        Click on first entry in list:
        element.selectedIndex: 0
        element.previousSelectedIndex: undefined
        Command-click on second entry in list:
        element.selectedIndex: 0
        element.previousSelectedIndex: 0
        You can see that the indexes are the same value, even though the selectedIndex should be '1'. When it works by clicking items going up the list:
        Click on second entry in list:
        element.selectedIndex: 1
        element.previousSelectedIndex: undefined
        Command-click on first entry in list:
        element.selectedIndex: 0
        element.previousSelectedIndex: 1
        In this case the two indexes are accurate (and different) so the submission occurs.

        Show
        Deryk Sinotte added a comment - - edited Kind of an interesting behaviour. When you click on a single entry going up or down the list, the component works fine. When you click on a single entry and then command click on another entry to select multiple values, the behaviour depends on whether or not you are going up or down. If you select the next item from below the first item, it fails. If you select an item above the first item it works. The issue is in the logic for the enableSingleSubmit code: if (0 == elementType.indexOf("select-")) { if (element.selectedIndex == element.previousSelectedIndex) { return; } else { element.previousSelectedIndex = element.selectedIndex; } } It checks to see if this is a "select-" element (which it is, checkboxes are "input" types so aren't affected by this logic). Next it checks to see if the selectedIndex is different from the previously selected index. If it is, it all works. If they are the same, it simply returns and no submit is done. If you watch those values in the client console. When it fails: Click on first entry in list: element.selectedIndex: 0 element.previousSelectedIndex: undefined Command-click on second entry in list: element.selectedIndex: 0 element.previousSelectedIndex: 0 You can see that the indexes are the same value, even though the selectedIndex should be '1'. When it works by clicking items going up the list: Click on second entry in list: element.selectedIndex: 1 element.previousSelectedIndex: undefined Command-click on first entry in list: element.selectedIndex: 0 element.previousSelectedIndex: 1 In this case the two indexes are accurate (and different) so the submission occurs.
        Hide
        Deryk Sinotte added a comment - - edited

        I've added some logic to our singleSubmit code to handle select-one and select-multiple types separately. The initial code wasn't doing this. The gist of the changes is that all the modern browsers now basically look for a "change" event to trigger the single submit. In the case of IE browsers pre-IE9, no change event appears to be available, so we manually try to determine if anything has changed.

        Show
        Deryk Sinotte added a comment - - edited I've added some logic to our singleSubmit code to handle select-one and select-multiple types separately. The initial code wasn't doing this. The gist of the changes is that all the modern browsers now basically look for a "change" event to trigger the single submit. In the case of IE browsers pre-IE9, no change event appears to be available, so we manually try to determine if anything has changed.
        Hide
        Deryk Sinotte added a comment -

        Some additional details. I've been mainly tinkering in application.js in the enableSingleSubmit section. One of the things we do when singleSubmit is enabled is to add some event listeners to the form:
        if (f.addEventListener)

        { //events for most browsers f.addEventListener('blur', submitForm, false); f.addEventListener('change', submitForm, false); }

        else

        { //events for IE f.attachEvent('onfocusout', submitForm); f.attachEvent('onclick', submitForm); }

        Triggering the submit on the change event works nicely in IE9 and the other browsers for most "select-*" type use cases but there is no onchange attached for pre-IE9 browsers. I tried attaching it myself using a couple of different techniques:
        f.attachEvent('onchange', submitForm);
        f.onclick = submitForm;
        but I never see the event. From what I'm reading, there's no straightforward way as the event doesn't bubble or get captured:
        http://msdn.microsoft.com/en-us/library/ie/ms536912(v=vs.85).aspx
        As it is, with IE 7/8, I currently have some manual code to check to see if the selection index and size of the selection have changed since the last interaction. Because of this, we need to rely on some combination of "click" and "focusout" for IE 7/8 in order to detect if something changed.

        Show
        Deryk Sinotte added a comment - Some additional details. I've been mainly tinkering in application.js in the enableSingleSubmit section. One of the things we do when singleSubmit is enabled is to add some event listeners to the form: if (f.addEventListener) { //events for most browsers f.addEventListener('blur', submitForm, false); f.addEventListener('change', submitForm, false); } else { //events for IE f.attachEvent('onfocusout', submitForm); f.attachEvent('onclick', submitForm); } Triggering the submit on the change event works nicely in IE9 and the other browsers for most "select-*" type use cases but there is no onchange attached for pre-IE9 browsers. I tried attaching it myself using a couple of different techniques: f.attachEvent('onchange', submitForm); f.onclick = submitForm; but I never see the event. From what I'm reading, there's no straightforward way as the event doesn't bubble or get captured: http://msdn.microsoft.com/en-us/library/ie/ms536912(v=vs.85).aspx As it is, with IE 7/8, I currently have some manual code to check to see if the selection index and size of the selection have changed since the last interaction. Because of this, we need to rely on some combination of "click" and "focusout" for IE 7/8 in order to detect if something changed.

          People

          • Assignee:
            Deryk Sinotte
            Reporter:
            Cruz Miraback
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: