Ibm mobilefirst 即使我添加了JSONStore,也无法使用它

Ibm mobilefirst 即使我添加了JSONStore,也无法使用它,ibm-mobilefirst,Ibm Mobilefirst,我正在使用MF 6.3.0.00.20150204-0610并使用混合应用程序。我将JSONStore添加到应用程序中,可以在applicationon-descriptor.xml中清楚地看到它。但是,当我尝试使用该功能时: def = WL.JSONStore.init("people").done(function() { console.log("Ok, I think I did the store?"); }); 我在控制台中遇到此错误: 错误:调用WL.JSONStore

我正在使用MF 6.3.0.00.20150204-0610并使用混合应用程序。我将JSONStore添加到应用程序中,可以在applicationon-descriptor.xml中清楚地看到它。但是,当我尝试使用该功能时:

def = WL.JSONStore.init("people").done(function() {
    console.log("Ok, I think I did the store?");
});
我在控制台中遇到此错误:

错误:调用WL.JSONStore.init失败,因为应用程序中缺少JSONStore。将JSONStore添加到应用程序描述符,重建并部署它


我现在肯定已经多次重建和部署了。

以下是我所做的,然后收到一条带有成功消息的警报:

  • 创建了一个新的项目和应用程序,添加了iPhone环境
  • 添加了JSONStore特性(从应用程序描述符设计视图)
  • 在common\js\main.js中:

    var def;
    
    function wlCommonInit(){
        def = WL.JSONStore.init("people").done(function() {
            alert("store created");
        }); 
    }
    
  • 右键单击iphone文件夹并选择RunAs>Xcode项目

  • 在XCode的iOS模拟器中运行应用程序
  • 收到以下警报
  • 我想问题应该是-您是如何初始化JSONStore的


    我刚刚尝试使用MFP CLI并使其正常工作。 这是我的个人设置:

    • JDK1.7和$JAVA_HOME set(MFP还不支持1.8)
    • MFP CLI版本6.3.0.00.20150204-0610(MFP-v)
    • 使用git在添加功能、构建和部署步骤上显示更改的文件
    • 使用MFP教程中的main.js
    终端上

        $ 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
    
    $ mfp bd
    
    common/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();
            });
    
        }
    
    终端上

        $ 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
    
    $ mfp bd
    
    开放XCode

    $ open iphone/native/MFPJSONSTOREMyappIphone.xcodeproj
    
    运行应用程序(即iOS模拟器iPhone 6)


    我通过CLI添加了该功能,然后使用了上面看到的代码。它在我的wlCommonInit里面。我尝试在浏览器模拟器和iPhone模拟器中进行测试,但在这两种情况下都失败了。我应该指定我只执行了“mfp添加功能”并选择了JSONStore。如果我还需要另一个步骤,我没有做。当然。:)我甚至尝试过停止和启动服务器。是否只有在尝试使用CLI或Studio时才会失败?我现在只使用CLI。能否提供一些有关您的环境的信息。运行命令“mfp info”并提供输出的信息。一旦我可以创建一个新项目(请参阅您正在帮助我的其他错误),我就可以尝试这个。