MyFaces Core
  1. MyFaces Core
  2. MYFACES-2640

(JSF.js) Ajax Render component problem, replace with whole fragment not one element.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 2.0.0-beta-3
    • Fix Version/s: 2.0.1
    • Component/s: JSR-314
    • Labels:
      None
    • Environment:
      tomcat 6.0.20 java (mac os x )

      Description

      after ajax submit, jsf.js will re-render some element depending on jsf.ajax.request(

      {render:" some elements "}

      );
      but this js code will cause some problem.

      jsf.js:

      myfaces._impl._util._Utils.replaceHtmlItem = function (request, context, itemIdToReplace, newTag, form)

      { ...... var fragment = range.createContextualFragment(newTag); evalNode = item.parentNode.replaceChild(fragment, item) ..... }

      sometime fragment will has more than one childNodes, or the childNode not has clientId, but the childNode of childNode has clientId.

      this will cause html unstable.

      Please fix it.

      this is my suggestion:

      myfaces._impl._util._Utils.replaceHtmlItem = function (request, context, itemIdToReplace, newTag, form)

      { ............. Orginal: var fragment = range.createContextualFragment(newTag); evalNode = item.parentNode.replaceChild(fragment, item) fix: var fragment = range.createContextualFragment(newTag); var replaceItem = myfaces._impl._util._Utils.findHtmlItemFromFragment(fragment, itemIdToReplace); if(replaceItem == null)replaceItem = fragment; evalNode = item.parentNode.replaceChild(replaceItem, item) .................. }

      myfaces._impl._util._Utils.findHtmlItemFromFragment = function(fragment, itemId){
      if(fragment.childNodes == null)
      return null;
      for(var i = 0; i < fragment.childNodes.length ; i++ )

      { var c = fragment.childNodes[i]; if(c.id == itemId) return c; }

      for(var i = 0; i < fragment.childNodes.length ; i++ )

      { var c = fragment.childNodes[i]; var item = myfaces._impl._util._Utils.findHtmlItemFromFragment(c, itemId); if(item != null) return item; }

      return null;
      };

        Activity

        Mark Li created issue -
        Mark Li made changes -
        Field Original Value New Value
        Original Estimate 24h [ 86400 ] 4h [ 14400 ]
        Remaining Estimate 24h [ 86400 ] 4h [ 14400 ]
        Affects Version/s 2.0.0-beta-3 [ 12314776 ]
        Component/s JSR-314 [ 12312453 ]
        Mark Li made changes -
        Description after ajax submit, jsf.js will re-render some element depending on jsf.ajax.request({render:" some elements "});
        but this js code will cause some problem.

        jsf.js:

        myfaces._impl._util._Utils.replaceHtmlItem = function (request, context, itemIdToReplace, newTag, form) {
        ......
                            var fragment = range.createContextualFragment(newTag);
                            evalNode = item.parentNode.replaceChild(fragment, item)
        .....
        }

        sometime fragment will has more than one childNodes, or the childNode not has clientId, but the childNode of childNode has clientId.

        this will cause html unstable.

        Please fix it.









        after ajax submit, jsf.js will re-render some element depending on jsf.ajax.request({render:" some elements "});
        but this js code will cause some problem.

        jsf.js:

        myfaces._impl._util._Utils.replaceHtmlItem = function (request, context, itemIdToReplace, newTag, form) {
        ......
                            var fragment = range.createContextualFragment(newTag);
                            evalNode = item.parentNode.replaceChild(fragment, item)
        .....
        }

        sometime fragment will has more than one childNodes, or the childNode not has clientId, but the childNode of childNode has clientId.

        this will cause html unstable.

        Please fix it.


        this is my suggestion:

        myfaces._impl._util._Utils.replaceHtmlItem = function (request, context, itemIdToReplace, newTag, form) {

                   .............
                      Orginal:
                            var fragment = range.createContextualFragment(newTag);
                            evalNode = item.parentNode.replaceChild(fragment, item)

                      fix:
                            var fragment = range.createContextualFragment(newTag);
                            var replaceItem = myfaces._impl._util._Utils.findHtmlItemFromFragment(fragment, itemIdToReplace);
                            if(replaceItem == null)replaceItem = fragment;
                            evalNode = item.parentNode.replaceChild(replaceItem, item)
               ..................
        }




            myfaces._impl._util._Utils.findHtmlItemFromFragment = function(fragment, itemId){
             if(fragment.childNodes == null)
             return null;
             for(var i = 0; i < fragment.childNodes.length ; i++ ){
             var c = fragment.childNodes[i];
             if(c.id == itemId)
             return c;
             }
             for(var i = 0; i < fragment.childNodes.length ; i++ ){
             var c = fragment.childNodes[i];
             var item = myfaces._impl._util._Utils.findHtmlItemFromFragment(c, itemId);
             if(item != null)
             return item;
             }
             return null;
            };




        Werner Punz made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0.1-SNAPSHOT [ 12314891 ]
        Resolution Invalid [ 6 ]
        Leonardo Uribe made changes -
        Fix Version/s 2.0.1 [ 12315117 ]
        Fix Version/s 2.0.1-SNAPSHOT [ 12314891 ]
        Leonardo Uribe made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Mark Li
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 4h
              4h
              Remaining:
              Remaining Estimate - 4h
              4h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development