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] Commented: (MYFACES-2640) (JSF.js) Ajax Render component problem, replace with whole fragment not one element.
Date Wed, 05 May 2010 09:27:02 GMT

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

Werner Punz commented on MYFACES-2640:
--------------------------------------

Hello Mark here is a full example which will showcase how to apply everything

            <h:commandLink id="button2" action="#{myBean2.doSearch}" value="press me for
next ajax">
               <f:ajax execute="@this" render="myDialog_placeHolder" />
            </h:commandLink>



            <h:panelGroup id="myDialog_placeHolder">
                <h:panelGroup styleClass="myDlg" id="myDialog">
                    <h:panelGroup id="content">
                        #{myBean2.refresh}
                    </h:panelGroup>

                </h:panelGroup>
                <script type="text/javascript">
                //<![CDATA[
                    /**
                     * we delay the dialog buildup slightly
                     * that way everything should be updated in the dom
                     */

                    if('undefined' == typeof myDialogInit) {
                        //at first rendering add a generic listener for this control
                        jsf.ajax.addOnEvent(function (data) {
                          if (data.status == "complete" && data.responseCode>=
200 && data.responseCode < 300) {
                              this.openStatus = $('#myDialog').dialog('isOpen');
                              $('#myDialog').dialog('destroy');$('#myDialog').remove();
                          } else if (data.status == "success") {
                              if(this.openStatus) {
                                $("#myDialog").dialog("open");
                              }
                          }
                        });
                        var myDialogInit = true;
                    }

                    $("#myDialog").dialog({autoOpen:false});
                //]]>
                </script>
            </h:panelGroup>




        </h:form>
        <script type="text/javascript">
            $("#myDialog").dialog("open");
        </script>

What happens is that a listener per dialog is registered once for this specific dialog which
takes care over the jquery cleanup process.

That should resolve your problem, nevertheless you have to be aware that the dialog itself
is ripped out of the form which  outside of the dialog.



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