You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Mark Li (JIRA)" <de...@myfaces.apache.org> on 2010/05/04 14:56:56 UTC

[jira] Issue Comment Edited: (MYFACES-2640) (JSF.js) Ajax Render component problem, replace with whole fragment not one element.

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

Mark Li edited comment on MYFACES-2640 at 5/4/10 8:55 AM:
----------------------------------------------------------

yes, a well designed component should always be wrapped into a root element.

but sometime it is difficult to put everything in one root element, in fact, I find this problem when I use my own component a float div. I use jQuery, I want to use simple component like 

component:
<lxht:component >
	<div id="#{clientId}">
		<div><lxht:insert/></div>
                  <script>
jQuery(document.getElementById('#{clientId}')).dialog({autoOpen:false});
                   </script>	
	</div>
</lxht:component>

jsf:

		<lxhs:test id="a">
			<h:form>
				<h:inputText value="#{TestBean.value}"></h:inputText>
				<lxhs:commandButton ajaxExecute="@form" ajaxRender="a"/>
			</h:form>
		</lxhs:test>
		<input type="button" value="show dialog" onclick="jQuery(document.getElementById('a')).dialog('open');"/>


when open the dialog, rend the dialog will casue display problem.


I think well-formated html doesnt mean a lot.  
html is old, writing html/ javascript which can run everywhere is very difficult.

if we just treat html as some text not xml, life will become easier.




      was (Author: puddlor):
    yes, a well designed component should always be wrapped into a root element.

but sometime it is difficult to put everything in one root element, in fact, I find this problem when I use my own component a float div. I use jQuery, I want to use simple design like 

<div id="clientId">
  <div class="content"></div>
  <script>jQuery('#clientId').dialog();</script>
</div>

but when ajaxrender clientid html component, the problem comes.
  
> (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
>             Fix For: 2.0.1-SNAPSHOT
>
>   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.