2013-07-02 32 views
1

面对一个奇怪的问题,工作灯适配器无法从模拟器调用。 LogCat给出以下错误无法从android模拟器调用时调用工作灯适配器

07-02 20:56:59.063: D/DroidGap(873): onMessage(onNativeReady,null) 
07-02 20:56:59.063: D/DroidGap(873): onMessage(onPageFinished,file:///data/data/com.PivMobileNew/files/www/default/PivMobileNew.html#clientListPage) 
07-02 20:56:59.513: D/PivMobileNew(873): --------- $('#clientListPage').bind('pageinit', function(event){ ------------ 
07-02 20:57:00.673: E/PivMobileNew(873): [http://10.202.4.254:1028/worklight/apps/services/api/PivMobileNew/android/query] exception. undefined is not a function 
07-02 20:57:00.823: D/CordovaLog(873): Uncaught TypeError: undefined is not a function 
07-02 20:57:00.823: D/CordovaLog(873): file:///data/data/com.PivMobileNew/files/www/default/wlclient/js/worklight.js: Line 1467 : Uncaught TypeError: undefined is not a function 
07-02 20:57:00.823: E/Web Console(873): Uncaught TypeError: undefined is not a function at file:///data/data/com.PivMobileNew/files/www/default/wlclient/js/worklight.js:1467 

但是,从常见的调用适配器它工作正常。

这里适配器调用代码...

function GetClient(strClientName) { 
    var invocationData = { 
      adapter : 'PivMobileAdapter' 
       ,procedure : 'getClient' 
        ,parameters: [{"ClientName":strClientName}] 
    }; 
    WL.Logger.debug(" --------- entered in function GetClient------- 2c"); 
    try { 
    WL.Client.invokeProcedure(invocationData, { 
     onSuccess : handleSuccess, 
     onFailure : handleFailure, 
    }); 
    } 
    catch (e) 
    { WL.Logger.debug("---inside try catch, error occured while invokingProcedure----"); 
     WL.Logger.debug(e.message); 
    } 

    function handleSuccess(result) { 
     WL.Logger.debug(" --------- inside handling success invoking procedure $('#searchNew').click(function() ------- 2c"); 
     ...some code here1... 
     ...some code here2... 
    } 

    function handleFailure(result) { 
     WL.Logger.debug(" --------- inside handling failure invoking procedure $('#searchNew').click(function() ------- 2c"); 
     ...some code here1... 
     ...some code here2... 
    } 
} 

不知道如何前进,谁能帮助?

+2

使用调用适配器过程的JavaScript编辑您的问题。 –

+0

添加了代码。 – Rajiv

+1

似乎它抱怨说它无法找到handleSuccess和handleFailure内部函数。 – tik27

回答

0

在使用引用之前,您必须定义onSuccess和onFailure处理函数。 您还需要将您的函数引用保存在变量中,因为您的代码已经在函数中。

var handleSuccess = function(xxx) { 
    // some code 
}; 

var handleFailure = function(xxx) { 
    // some code 
}; 
// references need to exist prior to passing them as callback handlers. 
WL.Client.invokeProcedure(invocationData, { 
     onSuccess : handleSuccess, 
     onFailure : handleFailure, 
}); 
+0

试过了,移动了上面的函数定义但仍然不起作用。回调函数是否需要像“handleSuccess”这样的引号? – Rajiv

+0

似乎在worklight库中存在问题。 – Rajiv

+0

我已经更新了我的答案。 你确定你的JavaScript函数被调用,或者当你的应用程序调用它时已经包含它吗? – MHeiss

相关问题