2016-04-19 11 views
0

JSONStoreにタスクのリストを保存し、ユーザーがfetchボタンをクリックするとそのリストを取得しようとしています。JSONストアがMobileFIrstハイブリッドアプリで断続的に失敗する

観察された動作:断続的にJSONStoreexceptionをスローし、格納されたタスクをまったくフェッチしないことがわかります。同じソースコードを再デプロイするとうまく動作します。意味は、タスクは期待どおりに格納され、フェッチされます。

/** 
* Function to add data to JSONStore collection 
* @param collName: Collection name to add to 
* @param dataToStore: data to store 
* @param flag: flag for operation, if CLEAR, collection is cleared before adding the new data 
* @param returnFunc: callback function for results handling 
*/ 
function Storage_add(collName,dataToStore,flag,returnFunc) { 
WL.Logger.debug('SU: Storage add function called.'); 
console.log('SU: Storage add function called.'); 

var result = {'result': true}; 
var collections = {}; 
collections[collName] = { 
     searchFields: {'id': 'string', 'processId' : 'string'} 
}; 
var addFunc = function(collectn,data2Store,returnFunc) { 
    WL.JSONStore.init(collections) 
    .then(function() { 
     WL.Logger.debug('Inside addFunc while adding to collection:'+collName); 
     console.log('Inside addFunc while adding to collection:'+collName); 
     WL.JSONStore.get(collName).add(data2Store, {push:true}) 
      .then(function (dataAdded) { 
       WL.Logger.debug('Data added to the collection '+collName+'--Success'); 
       console.log('Data added to the collection '+collName+'--Success'); 
       returnFunc({'result': true}); 
      }) 
      .fail(function (errorObject) { 
       // Handle failure for any of the previous JSONStore operations (init, add). 
       WL.Logger.debug('Error adding data to the collection:'+collectn); 
       console.log('Error adding data to the collection:'+collectn); 
       returnFunc({'error':'Error adding the data'}); 
      });  
    }) 
    .fail(function (errobject) { 
     WL.Logger.debug(errobject.toString()); 
     console.log(errobject.toString()); 
     returnFunc({'error':'JSONStore Error adding the data'}); 
    }); 
}; 
if(flag=='CLEAR') { 
    WL.JSONStore.init(collections) 
    .then(function() { 
     WL.Logger.debug('With flag clear, opened collection:'+collName); 
     console.log('With flag clear, opened collection:'+collName); 
     WL.JSONStore.get(collName).removeCollection() 
      .then(function() { 
       WL.Logger.debug('Cleared collection --Success'); 
       console.log('Cleared collection --Success'); 
       // Handle success. 
       addFunc(collName,dataToStore,returnFunc); 
      }) 
      .fail(function (errorObject) { 
       // Handle failure for any of the previous JSONStore operations (init, add). 
       WL.Logger.debug('Error clearing collection:'+collName); 
       console.log('Error clearing collection:'+collName); 
       returnFunc({'error':'Error clearing the data'}); 
      });  
    }); 

} else { 
    WL.Logger.debug('flag is not set as clear. About to call addFunc'); 
    console.log('flag is not set as clear. About to call addFunc'); 
    addFunc(collName,dataToStore,returnFunc); 
} 
    } 

読み込み機能:この問題は、製品の欠陥であってもよく、処理され

/** 
* Function to fetch a collection data in array form using its name 
* @param collName 
* @param returnFunc: callback function for results handling 
*/ 
function Storage_getArray(collName,returnFunc) { 
console.log('SU: Storage get collection Array called for Collection:'+collName); 
WL.Logger.debug('SU: Storage get collection Array called for Collection:'+collName); 
var returnArray = []; 

var collectionName = collName; 
var JSONStoreCollections = {}; 
JSONStoreCollections[collectionName] = {}; 
JSONStoreCollections[collectionName].searchFields = {'id': 'string', 'processId' : 'string'}; 

var funcRes = function(res) { 
    WL.Logger.debug('SU: Inside funcRes. No. of results:'+res.length); 
    console.log('no. of results:'+res.length); 
    WL.Logger.debug('res stringified:'+JSON.stringify(res)); 
    console.log('res stringified:'+JSON.stringify(res)); 
    if (res.length >= 1) { 
     console.log('res has values.'); 
     $.each(res, function (index, val) { 
      returnArray.push(val.json); //push values here 
     }); 
    } 
    WL.Logger.debug('SU: About to returnArray with length:'+returnArray.length); 
    console.log('About to returnArray with length:'+returnArray.length); 
    returnFunc(returnArray); 
}; 

WL.Logger.debug('SU: About to start Collection '+collName+'. collections var:'+JSON.stringify(JSONStoreCollections)); 
console.log('SU: About to start Collection '+collName+'. collections var:'+JSON.stringify(JSONStoreCollections)); 
WL.JSONStore.init(JSONStoreCollections) 
.then(function() { 
      //WL.Logger.debug('ts Init done'); 
     WL.Logger.debug('SU: Collection init done. about to find all'); 
     console.log('SU: Collection init done. about to find all'); 
     return WL.JSONStore.get(collName).findAll(); 
}) 
.then(funcRes) 
.fail(function (err) { 
     WL.Logger.debug('SU: Error caught for JSONStore init for collection:'+collName+'. err:'+err.toString()); 
     console.log('SU: Error caught for JSONStore init for collection:'+collName+'. err:'+err.toString()); 
     var retErr = {"error": "JSONStore"}; 
     returnFunc(err); 
}); 
} 
+0

使用しているモバイルファーストプラットフォームのバージョンを教えてください。どの機能がどのボタンに関連付けられているか。あなたはfetch関数が関数に結びついていると言っていますので、追加についてはどうですか?また、 'fetch'の前に' add'ボタンを押しますか? – Namfo

+0

srujan reddy、返信してください。 –

+0

@ surujan reddyこの問題は引き続き発生していますか? – DoraC

答えて

0

例外スローのメッセージが私たちの書き込みと読み取りの機能は以下のとおりです{"src":"find","err":22,"msg":"INVALID_SEARCH_FIELD","col":"CollectionTasksName","usr":"jsonstore","doc":{},"res":{}}

ですサポートチケット/ PMR番号28639,756,000の一部として提供されます。将来のiFixリリースでは、必要に応じて修正版が提供される予定です。

+0

この問題に対処するためにiFixが(上記のように)今はありますか?もしそうなら、iFixは何ですか?ありがとう。 –

関連する問題