Enabling WL.JSONStore in Worklight project from Eclipse? - ibm-mobilefirst

I have a project in eclipse and using IBM Worklight but on my js file where i have placed this code
WL.JSONStore.init(JSONStoreCollections).then(
function(res) {
WL.Logger.info('Response is :', res);
WL.JSONStore.get(chekVodafoneData).findAll()
I am getting a red mark under WL.JSON and it show JSONStore is not enabled ? I have already refered How to enable WL.JSONStore in Worklight project?, but it didn't helped much ?

The reason you are getting the error that JSONStore is not enabled is because it is an "optional feature" and must be enabled in the application-descriptor.xml file. Open this file in Eclipse, and in the "Design" tab simply right click "Optional Features" and select JSONStore. This should remove any errors stating that JSONStore is not enabled.
For implementation details of a JSONStore, see: JSONStore Infocenter (6.1)

Related

IBM Worklight 6.1 - How can I remove the Tealeaf library?

I need to remove the Tealeaf library from my Worklight application in order to have a lighter App (I'm using Eclipse Juno Service Release 2 Build id: 20130225-0426 with WorklightStudioPlugin version 6.1.0.01-20140311-2356 ).
I have modified my project following these steps:
In the application-descriptor.xml's Design view I've removed Optional Features > Analytics
Then I've removed the existing Tealeaf folder under native in iPhone’s environment
Finally I've removed from native\libs the library uicandroid.jar for Android
Is there any other option/configuration to set?
I receive the error below:
TLF_configurator.enable was called, but the required Tealeaf libraries are not present in the classpath.
I haven’t found any details in the official guide. There's only the procedure for adding Tealeaf, not for removing it.
If you remove the Analytics optional feature and rebuild your application/environments, it should have removed everything for you. Just changing the app descriptor XML file is not enough to do so. Did you rebuild your environment after removing the Analytics optional feature?
Also, make sure you are not enabling analytics in your code (by calling WL.Analytics.enable or setting analytics : {enabled : true} in your initOptions.js) and that you are not using the WL.Analytics API in your code.

IBM Worklight 6.0 - Worklight Starter Dojo example broken?

I've installed Worklight 6 in an instance of Eclipse Juno and I am wanting to migrate working apps into it from Eclipse Helios and Worklight 5. I am running into some strange problems, possibly because of the transition to Dojo 9 or maybe the new directory structure of the resident Dojo files. So I decided to start with the examples. I use Dojo in my apps, so I downloaded the WorklightStarter_DojoMobile eclipse project and imported it. I did the 'build and deploy' step, and also deployed the WorklightStarterAdapter.
I am trying to run the app in the browser simulator and it appears to be busted. I get the 'about' view but no feeds. I ran it with Firebug and the console shows a lot of peculiar errors.
I won't paste in the network links but a lot of files are not found:
WorklightStarter_DojoMobile/apps/services/preview/WorklightStarter_DojoMobile/android/1.0/default/cordova_plugins.json not found
WorklightStarter_DojoMobile/apps/services/preview/WorklightStarter_DojoMobile/android/1.0/default/dojo/core-web-layer.js not found
WorklightStarter_DojoMobile/apps/services/api/WorklightStarter_DojoMobile/android/init unauthorized
/WorklightStarter_DojoMobile/apps/services/preview/WorklightStarter_DojoMobile/android/1.0/default/dojox/mobile/themes/android/android-compat.css
Procedure invocation error. White spaces are required between publicId and systemId. Failed to parse the payload from backend (procedure: HttpRequest) with transformation...
Indeed, the Worklight Starter Dojo Edition is not fully compatible with Worklight 6; instead, you can use the Dojo examples from the training materials.

IBM Worklight 6.0 - Dojo library uses localhost after deploy

I have a Worklight 6.0 project that uses the new Dojo 1.9 libs, I created an external dojo project, like the documentation suggested, then, in the main project properties, under "Dojo toolkit", it references this dojo19 project.
The project works on the local server, then I did "Run As" | "Build for Remote Server...", and entered the correct domain:port and context path, clicked Build, the *.wlapp files were updated. (I've also updated the settings for publicWorkLightHostname / publicWorkLightPort / publicWorkLightProtocol in the "Environment Entries for Web Modules" in the installed war to match the remote server names/port/protocol.)
But, after deploying both war and -all.wlapp file, accessing the app I get JS errors when it tries to refer to the dojo19 library:
The page at
https://<myIP>:9443/<myproject>/apps/services/www/ /mobilewebapp/default/IODMobile.html
ran insecure content from http://localhost:64441/dojo19/<myproject>/IODMobile/mobilewebapp/dojo/nls/core-web-layer_en-us.js.
The dojo19 is the project name in my Worklight developer workspace that I referred to above.
Why is it trying localhost? Seems there's a missing step here in deploying the dojo library project into Worklight.
Where are you trying to preview the application when you get the error message?
See the changes in Dojo in Worklight 6.0
If launching the application in emulator/simulator/device, see Billy Rowe's answer in this question
Partial copy/paste:
Step 1: Verify your application works in the Mobile Browser Simulator
with Provide Library Resources checked. If the Console log is showing
resources being served from the server, then these have to be copied
to your application before deploying to AVD or a device
Step 2: After you think you have all Dojo/resources within your
project, uncheck Provide Library Resources and test it again in MBS.
If it fails in MBS, then something is missing in your application that
is in the library/server. You can check Provide Library Resources and
retest to see if it shows you what that is. Not all resources are
shown, e.g. if there's a missing CSS file.
Also I would suggest to do all of this in the Development environment (that is, in Eclipse) before starting to deploy the .war file and .wlapp file etc... (which, BTW, I hope you're doing based on the new instructions for Worklight 6.0)
In the information center, it will show you how to uncheck the Provide Library Resources in the Console Log.
I think what you're running into is:
1) Something is being served from the Dojo Library/Server
2) A bug in 6.0 that used "localhost" instead of the IP of the host (your machine running eclipse). This is fixed in the 6.0 iFix. With this fix, you can run your app external to Studio and still use the Dojo Library/Server. Without this fix, you must have everything you need within your app.
Can you install the iFix and let us know if that fixed the problem?

IBM Worklight - JSONStore is not working when trying to push the data to back end server

We are trying to push the data from IBM worklight application using JSONStore functionality.
We are working on IBM Worklight V5.0.6 environment.
Steps to reproduce:
Open Worklight 5.0.6 studio
import
'module_07_11_JSONStore_with_Sync' project into workspace
Accept
to migrate the project to latest Worklight version
Build & deploy
the app to Worklight server
Try to create JSONStore
At this stage we are getting the error:
JsonStoreWizard.InvokeProcedurePage got exception invoking adapter
Because of this, we are not able to create a new JSONStore instance.
What is the reason for getting this error?
After:
Accept to migrate the project to latest Worklight version
Expand the adapters folder > Right Click on the user folder > Select deploy Worklight Adapter and check it was deployed correctly in the console.
You may want to test the adapter in isolation too. "Invoke Adapter Procedure" from Eclipse.
There's no need to use the JSONStore Wizard to work with that sample, if I recall correctly. Just deploy the adapter, build all and deploy the app, open the Android or iPhone Worklight Application, play with the UI and read the source code.
I also recommend reading the JSONStore documentation especially the part under Adapter. Take a look at: WL.JSONStore, init, push, load and count. The examples should help you get data and push it back to your adapter.
If you run into issues, this StackOverflow answer can help you debug and provide more information if you ask JSONStore questions.
What is the reason for getting this error?
The JsonStoreWizard.InvokeProcedurePage error seems to indicate invoking the adapter failed. Leave a comment if you're still unable to push data back and I'll probably update this answer.

Does anyone know how to troubleshoot a Worklight SQL adapter?

I'm a newbie to Worklight. I have imported module 6.1 from the developerWorks getting started with Worklight sample http://www.ibm.com/developerworks/mobile/worklight/getting-started/
I am getting the error in the error as configured in the javascript
"Can't get cities list. Check database connection"
Does anyone know how to troubleshoot? The connection parameters in "SQLAdapter.xml" are very straight forward.
For the Worklight MySQL adapter request to reach the MySQL database, you need to add the mysql-connector-java-5.1.23-bin.jar to your project.
You can download the MySQL Connector/J file via this URL: http://dev.mysql.com/downloads/connector/j/
Choose "platform Independent" in the dropdown, and click the Download button for the .zip option.
Uncompress the .zip file and copy the mysql-connector-java-5.1.23-bin.jar to yourProject\server\lib.
Got it working. Seems there was a problem with my Eclipse install, or Java on Windows. So I switched back to causing my Eclipse and Java installed on IOS and all is working. Also, the IBM documentation was unclear, but now that I am using mysql-connector-java-5.1.23-bin.jar in my Project\server\lib folder.