[ 
https://issues.apache.org/jira/browse/MYFACES-2640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12862548#action_12862548
 ] 

Mark Li edited comment on MYFACES-2640 at 4/30/10 1:48 AM:
-----------------------------------------------------------

2. on IE6 the problem will not be fixed.

orginal:
    myfaces._impl._util._Utils.replaceHtmlItem = function (request, context, 
itemIdToReplace, newTag, form) {
.............
                } else {
                    item.insertAdjacentHTML("beforeBegin", newTag);
                    evalNode = item.previousSibling;
                    item.parentNode.removeChild(item);
                    if (item.id != "myfaces_bodyplaceholder" && ("undefined" == 
typeof evalNode.id || null == evalNode.id || evalNode.id != item.id)) {
                        var subNode = document.getElementById(item.id);
                        subNode.parentNode.removeChild(subNode);
                        evalNode.parentNode.replaceChild(subNode, evalNode)
                    }
                }
................
  }

fix:
    myfaces._impl._util._Utils.replaceHtmlItem = function (request, context, 
itemIdToReplace, newTag, form) {
.............
                } else {
//start 
                        var tmpElement = document.createElement("div");
                        tmpElement.innerHTML = newTag;
                    var replaceItem = 
myfaces._impl._util._Utils.findHtmlItemFromFragment(tmpElement, item.id);
                    if(replaceItem != null){
                        item.parentNode.insertBefore(replaceItem, item);
                        item.parentNode.removeChild(item);
                        evalNode = replaceItem;
                    }else{
//end

                            item.insertAdjacentHTML("beforeBegin", newTag);
                            evalNode = item.previousSibling;
                            item.parentNode.removeChild(item);
                    }
                    if (item.id != "myfaces_bodyplaceholder" && ("undefined" == 
typeof evalNode.id || null == evalNode.id || evalNode.id != item.id)) {
                        var subNode = document.getElementById(item.id);
                        subNode.parentNode.removeChild(subNode);
                        evalNode.parentNode.replaceChild(subNode, evalNode)
                    }
                }
................
  }

      was (Author: puddlor):
    2. on IE6 the problem will not be fixed.

orginal:
    myfaces._impl._util._Utils.replaceHtmlItem = function (request, context, 
itemIdToReplace, newTag, form) {
.............
                } else {
                    item.insertAdjacentHTML("beforeBegin", newTag);
                    evalNode = item.previousSibling;
                    item.parentNode.removeChild(item);
                    if (item.id != "myfaces_bodyplaceholder" && ("undefined" == 
typeof evalNode.id || null == evalNode.id || evalNode.id != item.id)) {
                        var subNode = document.getElementById(item.id);
                        subNode.parentNode.removeChild(subNode);
                        evalNode.parentNode.replaceChild(subNode, evalNode)
                    }
                }
................
  }

fix:
    myfaces._impl._util._Utils.replaceHtmlItem = function (request, context, 
itemIdToReplace, newTag, form) {
.............
                } else {
                        var tmpElement = document.createElement("div");
                        tmpElement.innerHTML = newTag;
                    var replaceItem = 
myfaces._impl._util._Utils.findHtmlItemFromFragment(tmpElement, item.id);
                    
                    if(replaceItem != null){
                        item.parentNode.insertBefore(replaceItem, item);
                        item.parentNode.removeChild(item);
                        evalNode = replaceItem;
                    }else{
                            item.insertAdjacentHTML("beforeBegin", newTag);
                            evalNode = item.previousSibling;
                            item.parentNode.removeChild(item);
                    }
                    if (item.id != "myfaces_bodyplaceholder" && ("undefined" == 
typeof evalNode.id || null == evalNode.id || evalNode.id != item.id)) {
                        var subNode = document.getElementById(item.id);
                        subNode.parentNode.removeChild(subNode);
                        evalNode.parentNode.replaceChild(subNode, evalNode)
                    }
                }
................
  }
  
> (JSF.js) Ajax Render component problem, replace with whole fragment not one 
> element.
> ------------------------------------------------------------------------------------
>
>                 Key: MYFACES-2640
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2640
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.0-beta-3
>         Environment: tomcat 6.0.20 java (mac os x )
>            Reporter: Mark Li
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> 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;
>     };

-- 
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