myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Li (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 Wed, 05 May 2010 04:52:05 GMT

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

Mark Li edited comment on MYFACES-2640 at 5/5/10 12:51 AM:
-----------------------------------------------------------

other bug.

		<h:form id="a">
			<h:commandButton action="#{TestBean.action}" value="submit"/>			
		</h:form>

		<h:form>
			<input type="button" value="ajax ReRender" onclick="jsf.ajax.request(this,event,{execute:'@form',render:'a',
onevent:function(data){alert(travelObjectString(data))}})"/>
		</h:form>

after ajax render h:form a, button submit cant work anymore.

when ajaxrender h:form, 
server returns:

,type:event
,status:success
,source:[object HTMLInputElement]
,responseXML:[object Document]
,responseText:<?xml version="1.0" encoding="utf-8"?><partial-response><changes><update
id="a"><![CDATA[<form id="a" name="a" method="post" action="/net.northking.omspublic/c.jsf"
enctype="application/x-www-form-urlencoded"><input id="a:j_id1643039915_61eeccea" name="a:j_id1643039915_61eeccea"
type="submit" value="submit" /><input type="hidden" name="a_SUBMIT" value="1" /></form>]]></update><update
id="javax.faces.ViewState"><![CDATA[kHvZEC3xUFrvph58FMXk3M1hmkXeI5frIq4lJC0k89Aes6jXgxar/a87bJnEgK+heJGFPEw2GymAluUJeQj83g==]]></update></changes></partial-response>
,responseCode:200

there is not <input type="hidden" id="javax.faces.ViewState"> inside <form id="a"></form>

its seems when  ViewHandler.writeState(FacesContext context), if(context.getPartialViewContext().isAjaxRequest())
will return directly, Why?

btw, not find useful stuff in specification (JSF_20090506.pdf)



      was (Author: puddlor):
    other bug.

		<h:form id="a">
			<h:commandButton action="#{TestBean.action}" value="submit"/>			
		</h:form>

		<h:form>
			<input type="button" value="ajax ReRender" onclick="jsf.ajax.request(this,event,{execute:'@form',render:'a',
onevent:function(data){alert(travelObjectString(data))}})"/>
		</h:form>

after ajax render h:form a, button submit cant work anymore.

when ajaxrender h:form, 
server returns:

,type:event
,status:success
,source:[object HTMLInputElement]
,responseXML:[object Document]
,responseText:<?xml version="1.0" encoding="utf-8"?><partial-response><changes><update
id="a"><![CDATA[<form id="a" name="a" method="post" action="/net.northking.omspublic/c.jsf"
enctype="application/x-www-form-urlencoded"><input id="a:j_id1643039915_61eeccea" name="a:j_id1643039915_61eeccea"
type="submit" value="submit" /><input type="hidden" name="a_SUBMIT" value="1" /></form>]]></update><update
id="javax.faces.ViewState"><![CDATA[kHvZEC3xUFrvph58FMXk3M1hmkXeI5frIq4lJC0k89Aes6jXgxar/a87bJnEgK+heJGFPEw2GymAluUJeQj83g==]]></update></changes></partial-response>
,responseCode:200

there is not <input type="hidden" id="javax.faces.ViewState"> inside <form id="a"></form>

its seems when  ViewHandler.writeState(FacesContext context), if(context.getPartialViewContext().isAjaxRequest())
will return directly, Why?




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


Mime
View raw message