【问题标题】:IBM Worklight Mobile invokation of SQL adapter not displaying recordsSQL 适配器的 IBM Worklight Mobile 调用不显示记录
【发布时间】:2018-12-30 20:37:17
【问题描述】:

根据 ibm 文档和其他博客,我尝试调用 SQL 适配器以在移动模拟器中显示结果。

遵循文档“Module_06__-_Invoking_Adapter_Procedures_from_the_Client_Applications.pdf”。

以下是我的代码:- 步骤1 MOBISQLAdap1-impl.js

var procedure1Statement = WL.Server.createSQLStatement("select * from sqldb.dbo.table1");
function procedure1(param) {
    return WL.Server.invokeSQLStatement({
        preparedStatement : procedure1Statement,
        parameters : [param]
    });
}

在调用 SQL 适配器时,它会显示结果。一切都好!

第 2 步:- 创建一个 名为 Mobi 的应用

第 3 步:- common/js/initOptions.js 在 common/js/initOptions.js 文件中;取消注释该行并且值为 true。

var wlInitOptions = {
// # Should application automatically attempt to connect to Worklight Server on application start up
// # The default value is true, we are overriding it to false here.
    connectOnStartup : true,

第 4 步:common/js/main.js 文件

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

    WL.Client.invokeProcedure(invocationData,{
        onSuccess : loadSQLQuerySuccess,
        onFailure : loadSQLQueryFailure
    });
}

function loadSQLQuerySuccess(result){
    WL.Logger.debug("Retrieve success" +  JSON.stringify(result));
    displayFeeds(result.invocationResult.resultSet);
}

function loadSQLQueryFailure(result){
    WL.Logger.error("Retrieve failure");
}

第五步:common/js/index.html文件;在正文部分

<body id="content" style="display: none;">
              <div id="itemsList"></div>
    <!--application UI goes here-->
    Display of data
    <script src="js/initOptions.js"></script>
    <script src="js/main.js"></script>
    <script src="js/messages.js"></script>
</body>

预览时,SQL 适配器值不会显示在应用程序中。在预览之前进行构建和部署。

任何帮助表示赞赏。谢谢rb

【问题讨论】:

  • 预览应用时,打开 Chrome 开发工具并在控制台中查看 - 你在那里看到了什么?有什么错误吗?此外,您已经列出了所有代码——除了 displayFeeds(),它实际上显示了提要!将此代码添加到问题中。

标签: mobile ibm-mobilefirst adapter procedure


【解决方案1】:

您从问题中省略了最重要的代码 sn-p - displayFeeds(),因此无法调试!

此外,您没有提及是否有任何错误 - 打开 Chrome 开发工具 > 控制台并查看预览应用时是否有任何错误。

最后,这个问题已经被问过很多次了。请搜索。
以下是处理同一问题的几个问题。

【讨论】:

  • 谢谢伊丹。 Atlast 发现了在显示源中以 HTML 格式显示 JSON 的问题。非常感谢您的即时回复。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-12
  • 1970-01-01
  • 2016-01-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多