M
mflanegan
Guest
Once you have saved your jsdo to local storage and you want to read from it again it throws the Exception while executing readLocal() error. Here im saving to local memory: function jsdoTest() { var jsdo = WebService_beBasicSearch_JSDO.jsdo; try { jsdo.saveLocal(); console.log('retrievedObject save: ', JSON.stringify(jsdo.getData())); } catch(e) { console.log("Exception while executing saveLocal();"); } } Here im trying to read from that local storage in a separate function to display my records into another datagrid on another page and the below causes an error. function hasRecords() { try { var hasLocalData = jsdo.readLocal(); console.log('retrievedObject read: ', JSON.stringify(jsdo.getData())); } catch(e) { console.log("Exception while executing readLocal();"); } } Its most likely because I don’t have the jsdo defined in the other fuction on the other page. How do you find that jsdo in the other function that is saved to local memory? Meyrick Flanegan Developer - Managed Services Email: mflanegan@elcb.co.za ELCB Information Services (Pty) Ltd Customer Service Email elcb@elcb.co.za · www.elcb.co.za E A S T L O N D O N Tel: +27(43) 704 0700 Fax: +27(43) 704 0701 J O H A N N E S B U R G Tel: +27(11) 879 6179 Fax: +27(11) 454 0384 P O R T E L I Z A B E T H Tel: +27(41) 373 0529 Fax: +27(86) 650 0135 Disclaimer From: egarcia [mailto:bounce-egarcia@community.progress.com] Sent: 11 December 2014 01:17 PM To: TU.Mobile@community.progress.com Subject: RE: [Technical Users - Mobile] Storing values in dataset RE: Storing values in dataset Reply by egarcia Hello Meyrick, The jsdo object is a reference that points to Session object which also points to the JSDOs that it contains. Calling JSON.stringify() for the jsdo reference would give you the exception "Converting circular structure to JSON". In this scenario, you actual want to get to just the data of the JSDO (jsdo.getData()). You can call getData() to get to the data and then call addRecords() to populate the JSDO. In release 3.1 of Mobile, we have added new APIs to the JSDO to save the data to local storage and then retrieve it. The APIs are the following: - saveLocal() - readLocal() - addLocalRecords() - deleteLocal() The methods use a default "local storage area" name but you can specify a parameter if you prefer to use a different name. By default all the data in the JSDO (data and changes) are stored. There is a parameter that you can specify to only save the changes. There are also support methods hasData() and hasChanges(). Here is how your could would look with the new APIs: function jsdoTest() { var jsdo = WebService_beBasicSearch_JSDO.jsdo; // Put the object into storage try { jsdo.saveLocal(); } catch(e) { console.log("Exception while executing saveLocal();"); } // Retrieve the object from storage try { var hasLocalData = jsdo.readLocal(); } catch(e) { console.log("Exception while executing readLocal();"); } console.log('retrievedObject: ', JSON.stringify(jsdo.getData())); } I hope this helps. Stop receiving emails on this subject. Flag this post as spam/abuse.
Continue reading...
Continue reading...