myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Werner Punz (JIRA)" <...@myfaces.apache.org>
Subject [jira] Issue Comment Edited: (MYFACES-2640) (JSF.js) Ajax Render component problem, replace with whole fragment not one element.
Date Sat, 03 Apr 2010 11:03:27 GMT

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

Werner Punz edited comment on MYFACES-2640 at 4/3/10 11:02 AM:
---------------------------------------------------------------

Ok I will look at it next week, I have to do some testing, this probably was a bug on my side,
since I assumed a fragment usually is just one node, (which  in most cases it is I will fix
that after the weekend)

Thing is, that usually the update edit and insert, works exactly on one element per block,
hence usually the fragment replacement also has an outer element, which is exactly one root
node.

What you do is recursively search the fragment for an item which has the identifier for the
replacement.

I am not quite sure if we have really a usecase where this is necessary since 
update, insert, delete work exactly on the items and should deliver them back with one root
node with the exact replacement element and its childnodes.
The only way I can see that the current mechanism is a problem is if you trigger the update
insert etc.. directly and have some content in which normally would not be rendered by the
normal PPR Response.
(Some kind of decorating html which then is omitted)


Can you give me an exact usecase where you ran into this problem, so that I get a cleaner
picture? 

      was (Author: werpu):
    Ok I will look at it next week, I have to do some testing, this probably was a bug on
my side, since I assumed a fragment usually is just one node, (which  in most cases it is
I will fix that after the weekend)

Thing is, that usually the update edit and insert, works exactly on one element per block,
hence usually the fragment replacement also has an outer element, which is exactly one root
node.

What maybe missing is an enclosing node in case of having multiple childs for an insert or
update, so I think the fix for this is to enclose it in case of having multiple children in
the same type as the element which has to be replaced.

Can you give me an exact usecase where you ran into this problem, so that I get a cleaner
picture?

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


Mime
View raw message