2012-07-25 70 views
0

Im新的工作燈。現在我開始使用適配器。檢查這個鏈接我的一個stackoverflow的朋友有同樣的疑問click this調用應用程序內的程序。使用的適配器是SqlAdapter。但是在ibm worklight教程中,他們給出了HttpAdapter的例子,並在函數中關注了該過程。但不適用於SqlAdapter。如果有任何建議,請讓我知道。如果你想我的來源,我會準備提供。我的研究仍在繼續如何在工作燈中的應用程序內使用適配器

回答

1

enter image description here

在這裏,我檢索的值。但它不顯示在html頁面中。這是我的代碼

function wlCommonInit(){ 
    // Common initialization code goes here 
    WL.Logger.debug("inside the wlcommoninit"); 
    busyIndicator = new WL.BusyIndicator('AppBody'); 
    getData(); 

} 






function loadFeedsSuccess(result){ 
    WL.Logger.debug("Feed retrieve success"); 

} 

function loadFeedsFailure(result){ 
    WL.Logger.error("Feed retrieve failure"); 

} 


function getData() { 
    var invocationData = { 
      adapter : 'SqlAdap', 
      procedure : 'procedure1', 
      parameters : [] 
     }; 

    WL.Client.invokeProcedure(invocationData,{ 
     onSuccess : loadFeedsSuccess, 
     onFailure : loadFeedsFailure, 
    }); 
    } 
+0

在附件中可以看到從服務器收到的結果。 而在控制檯中,您會看到您得到了loadFeedsSuccess函數(「Feed檢索成功」消息)。 現在,您只需使用loadFeedsSuccess函數中收到的JSON對象 (例如,嘗試類似WL.Logger.debug(result.resultSet [0] .des))。 – 2012-07-26 07:52:55

+0

@ravidor它爲我工作。好回覆 – 2012-07-27 05:03:12

+0

酷!如果它對你有用,你能投票選出答案嗎? :) – 2012-07-27 21:44:53

3

從應用程序到適配器的調用對於所有類型的適配器都是相同的。

function getData() { 
var invocationData = { 
     adapter : 'ADAPTER_NAME', 
     procedure : 'PROCEDURE_NAME', 
     parameters : [] 
    }; 

WL.Client.invokeProcedure(invocationData,{ 
    onSuccess : getDataSuccess, 
    onFailure : getDataFailure, 
}); 
} 

有關詳細信息檢查module 6 - Invoking Adapter Procedures from the Client Applications (PDF, 370KB)the exercise and code sample (ZIP, 53.7KB)

+0

Atlast我能夠從數據庫檢索值。那是在控制檯中顯示的。現在的問題,我不知道如何檢索到HTML頁面的值 – 2012-07-26 05:50:50

+0

我已經回答了這個問題http://stackoverflow.com/questions/11611058/how-to-make-https-requests-with-serverside-javascript-使用工作燈 – 2012-07-31 16:33:00