简体   繁体   English

我添加它后,无法使用JSONStore

[英]Unable to use JSONStore even after I added it

I'm using MF 6.3.0.00.20150204-0610 and working with a hybrid application. 我正在使用MF 6.3.0.00.20150204-0610并使用混合应用程序。 I added JSONStore to the app and can see it clearly in applicaiton-descriptor.xml. 我在应用程序中添加了JSONStore,可以在applicaiton-descriptor.xml中清楚地看到它。 However, when I try to use the feature: 但是,当我尝试使用该功能时:

def = WL.JSONStore.init("people").done(function() {
    console.log("Ok, I think I did the store?");
});

I get this error in the console: 我在控制台中收到此错误:

Error: Failed to call WL.JSONStore.init because JSONStore is missing in the application. 错误:无法调用WL.JSONStore.init,因为应用程序中缺少JSONStore。 Add JSONStore to the application descriptor, rebuild and deploy it. 将JSONStore添加到应用程序描述符,重建并部署它。

I've definitely rebuilt and deployed now - multiple times. 我现在肯定已经重建和部署 - 多次。

Here's what I did followed by getting an alert with a sucess message: 这是我所做的,然后通过成功消息获取警报:

  1. Created a new project and application, added the iPhone environment 创建了一个新项目和应用程序,添加了iPhone环境
  2. Added the JSONStore feature (from the Application Descriptor design view) 添加了JSONStore功能(来自Application Descriptor设计视图)
  3. In common\\js\\main.js: 共同的\\ js \\ main.js:

     var def; function wlCommonInit(){ def = WL.JSONStore.init("people").done(function() { alert("store created"); }); } 
  4. Right-click the iphone folder and select Run As > Xcode project 右键单击iphone文件夹,然后选择Run As> Xcode project

  5. Run the app in XCode's iOS Simulator 在XCode的iOS模拟器中运行该应用程序
  6. Got the following alert 得到以下警报

I suppose the question should be - how did you initialize JSONStore? 我想问题应该是 - 你是如何初始化JSONStore的?

在此输入图像描述

I just tried using the MFP CLI and got it working. 我刚刚尝试使用MFP CLI并使其正常工作。 Here is my personal setup: 这是我的个人设置:

  • JDK 1.7 and $JAVA_HOME set (MFP doesn't support 1.8 yet) JDK 1.7和$ JAVA_HOME设置(MFP尚不支持1.8)
  • MFP CLI version 6.3.0.00.20150204-0610 (mfp -v) MFP CLI版本6.3.0.00.20150204-0610(mfp -v)
  • Using git to show changed files on steps add feature, build, and deploy 使用git在步骤上显示已更改的文件,添加功能,构建和部署
  • Using main.js from MFP Tutorial JSONStore – JavaScript API 使用MFP Tutorial JSONStore中的main.js - JavaScript API

On Terminal 在终端上

    $ javac -version

    javac 1.7.0_72

    $ echo $JAVA_HOME

    /Library/Java/JavaVirtualMachines/jdk1.7.0_72.jdk/Contents/Home

    $ mfp -v

    6.3.0.00.20150204-0610


    $ mfp create MFPJSONSTORE
    A MobileFirst Project was successfully created at /Users/mfpuser/foo/mfp/6.3/MFPJSONSTORE

    $ cd MFPJSONSTORE/

    $ mfp add hybrid
    [?] What do you want to name your MobileFirst App? myapp
    A new Hybrid App was added at /Users/mfpuser/foo/mfp/6.3/MFPJSONSTORE/apps/myapp

    $ mfp add environment
    [?] What environments you want to add to the hybrid app? iPhone
    A new iphone Environment was added at /Users/mfpuser/foo/mfp/6.3/MFPJSONSTORE/apps/myapp/iphone

    $ mfp start
    Cannot find the server configuration. Creating a new MobileFirst test server.
    Initializing MobileFirst Console.
    objc[779]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_72.jdk/Contents/Home/jre/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_72.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
    Starting server worklight.
    Server worklight started with process ID 778.

    $ cd apps/myapp

    $ mfp add feature
    [?] What feature you want to install in this application? NOTE: Features you have already installed are not shown: JSONStore
    A new jsonstore Feature was added at /Users/mfpuser/foo/mfp/6.3/MFPJSONSTORE/apps/myapp

    $ git status
    On branch master
    Changes not staged for commit:

        modified:   application-descriptor.xml

    $ git commit -am "added feature jsonstore"

    $ mfp build
    App myapp was successfully built.

    $ git status
    On branch master
    Changes not staged for commit:

        modified:   iphone/native/www/default/filelist
        modified:   iphone/native/www/default/index.html
        modified:   iphone/native/www/default/worklight/checksum.js
        modified:   ../../bin/myapp-all.wlapp
        modified:   ../../bin/myapp-common.wlapp
        modified:   ../../bin/myapp-iphone-1.0.wlapp

    Untracked files:

        iphone/native/www/default/worklight/jsonstore.js

    $ git add iphone/

    $ git status
    On branch master
    Changes to be committed:

        modified:   iphone/native/www/default/filelist
        modified:   iphone/native/www/default/index.html
        modified:   iphone/native/www/default/worklight/checksum.js
        new file:   iphone/native/www/default/worklight/jsonstore.js

    Changes not staged for commit:

        modified:   ../../bin/myapp-all.wlapp
        modified:   ../../bin/myapp-common.wlapp
        modified:   ../../bin/myapp-iphone-1.0.wlapp

    $ git commit -am "after mfp build with jsonstore"

    $ mfp deploy
    App myapp was successfully deployed.

    $ git status
    On branch master
    nothing to commit, working directory clean

common/js/main.js: 通用/ JS / main.js:

    function wlCommonInit(){

        WL.JSONStore.destroy()

        .then(function () {

            var collections = {
                    people : {
                        searchFields: {name: 'string', age: 'integer'}
                    }
            };

            return WL.JSONStore.init(collections);
        })

        .then(function () {

            var data = [{name: 'carlos', age: 20},
                        {name: 'mike', age: 30}];

            return WL.JSONStore.get('people').add(data);
        })

        .then(function () {
            return WL.JSONStore.get('people').findAll();
        })

        .then(function (res) {

            console.log("result from prople findAll:");
            var resultdiv = document.createElement("div");
            var resultsJson = JSON.stringify(res);
            resultdiv.innerText = resultsJson;
            document.body.appendChild(resultdiv);
            console.log(resultsJson)
        })

        .fail(function (err) {
            ok(false, 'Got failure: ' + err.toString());
            start();
        });

    }

On Terminal 在终端上

$ mfp bd

Open XCode 打开XCode

$ open iphone/native/MFPJSONSTOREMyappIphone.xcodeproj

Run App (ie iOS Simulator iPhone 6) 运行应用程序(即iOS模拟器iPhone 6)

在此输入图像描述

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

相关问题 即使删除了该应用程序,来自Worklight的JSONStore数据/文档是否仍可在设备(iPhone / Android)上保留? - Does the JSONStore data/documents from Worklight persist on device (iPhone/Android) even after deleting the App? IBM Worklight-如何在应用程序中使用2个JSONStore集合 - IBM worklight - How to use 2 JSONStore collections in the applications 无法将cordova-plugin-mfp-jsonstore安装到cordova android平台 - unable to install cordova-plugin-mfp-jsonstore to cordova android platform IBM Worklight-直接更新后JSONStore无法初始化 - IBM Worklight - JSONStore fails to initialize after Direct Update 从jsonstore集合中删除文档后,对象为空 - Null objects after removing document from jsonstore collection 在JSONStore中存储后,JSON Date属性被解析为本地时区 - JSON Date attribute is parsed to local time zone after storing in JSONStore 从Worklight 5.0.6迁移后,IBM Worklight 6.0-预览中出现JSONStore错误 - IBM Worklight 6.0 - JSONStore error in preview after migrating from Worklight 5.0.6 IBM Worklight 6.0-如何将JSONStore的同步功能与SQL适配器一起使用 - IBM Worklight 6.0 - How to use JSONStore's sync ability with a SQL adapter Worklight 5.06-如何从JSONStore检索大量数据? - Worklight 5.06 - How can I retrieve a large amount of data from JSONStore? JSONStore代码无法正常工作 - JSONStore code not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM