Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
laurentC
Posts: 266
Registered: ‎02-05-2010
My Device: Blackberry Z10
My Carrier: Bouygues Telecom

Error blackberry is not defined

Hi,

 

I'm working on a PlayBook app (PlayBook OS not BB10) and I'm facing an issue when I launch it on Ripple.

 

My confix.xml file :

<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="2.0.0.0">
<name>Next Songs</name>
<author>LaurentCie</author>
<rim:smileysurprised:rientation mode="landscape" />
<rim:loadingScreen backgroundColor="#000000" />
<rim:smileytongue:ermissions>
<rim:smileytongue:ermit>access_shared</rim:smileytongue:ermit>
</rim:smileytongue:ermissions>
<icon src="iconApp/nextSongsIcon.png"/>
<content src="index.html"/>
<feature id="blackberry.app"/>
<feature id="blackberry.io.dir" />
<feature id="blackberry.utils" />
<feature id="blackberry.io.file" />
</widget>

 

In my javascript I'm trying to retieve the object appDirs with :

vardirs = blackberry.io.dir.appDirs;

 

But it's not working, I got the error : Uncaught execption blackberry is not defined.

 

I searched on google and the forum and the only solution I've found is addind <feature id="blackberry.io.dir" /> in the config.xml file and it should work. But it is NOT !

 

Why ? Could you help ?

 

Before trying to use  blackberry.io.dir.appDirs, my app was working fine in the simulator. I successfuly packaged it and it works fine on my tablet but after adding vardirs = blackberry.io.dir.appDirs; it's not anymore. 

 

I'm not sure what I'm doing wrong...

 

Thanks for your help,

Laurent

Twitter : @LaurentKP
My apps
Please use plain text.
Developer
laurentC
Posts: 266
Registered: ‎02-05-2010
My Device: Blackberry Z10
My Carrier: Bouygues Telecom

Please help !!!!!

Please help !!!!!!!

I tried to reinstall the ripple extensions but I got the same error.

 

Maybe it's a trouble with Sencha Touch 2.1

I tried an other project build with Sencha Touch 1.1 and I don't have such errors whereas I have blackberry.media.camera.takePicture(successCB, closedCB, errorCB); in my code.

 

How should I refer to  blackberry.io.dir.appDirs with Sencha Touch 2.1 ???

Twitter : @LaurentKP
My apps
Please use plain text.
Developer
laurentC
Posts: 266
Registered: ‎02-05-2010
My Device: Blackberry Z10
My Carrier: Bouygues Telecom

Re: Please help !!!!!

I've found a similar issue while accessing PlayBook directories on the forum :
http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/blackberry-io-dir-appDirs-not-wo...

It looks like I forgot the "access subdomains" part in my config.xml.
I also didn't mention required="true" in my feature elements : <feature id="blackberry.io.dir" required="true"/>

I'll test with the config.xml below and let you know if it works :

<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
        xmlns:rim="http://www.blackberry.com/ns/widgets"
        version="2.0.0.0">
  <name>Next Songs</name>
  <author>LaurentCie</author>  
  <rim:smileysurprised:rientation mode="landscape" />  
  <rim:loadingScreen backgroundColor="#000000" />  
  <icon src="iconApp/nextSongsIcon.png"/>
  <content src="index.html"/>    
     
  <rim:smileytongue:ermissions>
    <rim:smileytongue:ermit>access_shared</rim:smileytongue:ermit>
  </rim:smileytongue:ermissions>

  <!-- Allow local *.html pages to access these APIs -->
  <feature id="blackberry.io.file" required="true"/>
  <feature id="blackberry.io.dir" required="true"/>

  <access subdomains="true" uri="file:///accounts/">
    <feature id="blackberry.app.event" required="true"/>
    <feature id="blackberry.app" required="true"/>
    <feature id="blackberry.system.event" required="true"/>
    <feature id="blackberry.invoke"/>
    <feature id="blackberry.io.file" required="true"/>
    <feature id="blackberry.io.dir" required="true"/>
    <feature id="blackberry.ui.dialog"/>
  </access>
 
 
</widget>

Twitter : @LaurentKP
My apps
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Please help !!!!!

Hi there,

 

Just to confirm, are you waiting for the webworksready event to be triggered before you access the blackberry object?

https://developer.blackberry.com/html5/documentation/getting_started_with_bb10_ww_sdk_2007056_11.htm...


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
laurentC
Posts: 266
Registered: ‎02-05-2010
My Device: Blackberry Z10
My Carrier: Bouygues Telecom

Re: Please help !!!!!

It's not a BB10 app. I'm working on a PlayBook OS 2 application. 

I need to access the file system, especially the music folder.

 

I just need :

blackberry.io.dir.appDirs

blackberry.io.dir.listDirectories

blackberry.io.dir.listFiles

 

I got the same error with the config.xml below :smileymad:

Uncaught ReferenceError: blackberry is not defined

Ripple :: Environment Warming Up (Tea. Earl Gray. Hot.)
webworks.tablet :: Initialization Finished (Make it so.)
eula response: true

 

Twitter : @LaurentKP
My apps
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Please help !!!!!

Apologies, you even said not BB10 in your initial post but somehow my brain read it as just BB10.

 

Have you by chance connected Web Inspector to see if any other errors are actually occurring? Perhaps the webworks.js file isn't fully loading? Even without the webworkready requirement, I would still recommend at least waiting until DOMContentLoaded is triggered to ensure the DOM and its scripts are all ready.

 

I'll put together a sample application to see if I can get it running. To be clear, the goal here is to enable file access to the shared music folder, correct?


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
laurentC
Posts: 266
Registered: ‎02-05-2010
My Device: Blackberry Z10
My Carrier: Bouygues Telecom

Re: Error blackberry is not defined

Yes I want to access the shared music folder. When you say the web inspector, it's on the PlayBook right. I'm still testing on my PC with ripple. I tried once on the PlayBook with the same issue. You may be right when you say the webworks.Js file is not fully loaded but how can I control that.

I'm working with Sencha Touch 2.1. I don't know how it works...
Twitter : @LaurentKP
My apps
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Error blackberry is not defined

Web Inspector can be accessed:

  • In Chrome / Ripple by right-clicking on the screen and selecting Inspect Element.
  • In the PlayBook browser, however since you require WebWorks, this isn't an ideal approach.
  • From a packaged WebWorks application on the PlayBook, by enabling debug mode when the application is packaged. This will launch the Web Inspector on a specific IP/PORT and you can browse there on your PC to view the web inspector.

Web Inspector documentation for reference:

https://developer.blackberry.com/html5/documentation/web_inspector_overview_1553586_11.html

 

In your case, I would stick with Ripple for now as the FILE APIs are supported there. Bring up Web Inspector, and verify:

  • In the Console panel, are there any errors being displayed when you load the application?
  • In the Network panel, is the webworks.js file being successfully loaded? (Status should be 200: OK)

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
laurentC
Posts: 266
Registered: ‎02-05-2010
My Device: Blackberry Z10
My Carrier: Bouygues Telecom

Re: Error blackberry is not defined

[ Edited ]

Console :

  1. Uncaught ReferenceError: blackberry is not defined app.js:137
Ripple :: Environment Warming Up (Tea. Earl Gray. Hot.) ripple.js:475
webworks.tablet :: Initialization Finished (Make it so.) ripple.js:475
eula response: true ripple.js:483
  1. Uncaught TypeError: Cannot read property 'children' of null ripple.js:479
    1. c.dir.listDirectories
      ....
      ...
       
      I can't see webworks.js in the networks panel because ripple.js failed.
Twitter : @LaurentKP
My apps
Please use plain text.
Developer
laurentC
Posts: 266
Registered: ‎02-05-2010
My Device: Blackberry Z10
My Carrier: Bouygues Telecom

Re: Error blackberry is not defined

When I try :

 

try {
dirs = blackberry.io.dir.appDirs;
}
catch(e) {
alert('error');
}

 

instead of 

dirs = blackberry.io.dir.appDirs;

 

I got the error alert but I can see more things in the networks panel. But no webworks.js !

 

Twitter : @LaurentKP
My apps
Please use plain text.