简体   繁体   English

使用jQuery在JSF中异步加载t:dataTable

[英]loading t:dataTable in JSF asynchronously using jQuery

<t:panelTab label="Detailed View" styleClass="tabFont" rendered="true" id="DetailedView">
    <t:dataTable value="#{MyFinanceBB.amendDataList}" id="DetailedViewGrid" forceId="true"
                var="myVo" rowIndexVar="gridExpRowNo"......>
    ...............
      <t:inputText value="#{myVo.myval}" styleClass="BodyFont" forceId="true" id="myId2"
                                    onchange="getTotalMyValAjax('myId2[#{gridExpRowNo}]',#{gridExpRowNo});">

/ ---------------------------------------------------------------- / / ------------------------------------------------- --------------- /

function getMyAmountTotalGrid(myidVar,count){   

            var myAmt=document.getElementById(myidVar).value;

            var id = 'myForm\\:targetView';

                $j.ajax({
                    async:"false",
                    cache:"false",
                    type: "POST",
                    url:"/myProj/myController",
                    data:{myAmt:myAmt,count:count},
                    error:function(){
                        alert('Error Occurred.Please try later');
                        },  
                    success:function(output){
                                alert('SUCCESS');
                                 $j('#'+id).load("/pagesmyProj/Home/dingDongHome.jsf");
                                alert('after reloading grid');                                          
                        }
                    }); 
        }

when i execute the code alert message SUCCESS is getting printed and all the server side variables are getting updated.(I came to know this by sysouts). 当我执行代码警报消息时,成功消息已被打印出来,并且所有服务器端变量都已更新。 But nothing is really getting changed in the webpage. 但是网页上的内容并没有真正改变。 The alert message "after relaoding grid" is also getting printed. 警报消息“重新网格放置后”也将被打印。 But the grid is not getting reloaded. 但是网格没有被重新加载。 The server side changes are not getting reflected in the browser. 服务器端的更改未反映在浏览器中。

For start you should add \\\\ to your id 首先,您应该在ID中添加\\\\

instead of var id = 'myForm:targetView'; 而不是var id = 'myForm:targetView';

write var id = 'myForm\\\\:targetView'; var id = 'myForm\\\\:targetView'; otherwise jquery selector by id wont work (you need to escape the : ) 通过ID否则jQuery选择不会工作(你需要躲避:

You are referencing 您正在引用

$j('#'+id)...

just remove the "j", ex. 只需删除“ j”,例如。 $('#'+id)... $( '#' + id)的...

经过长时间的努力,我得到了错误。给jquery加载函数的url不正确,应该更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM