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
New Contributor
Posts: 6
Registered: ‎02-21-2011
My Device: Blackberry Bold 9700
My Carrier: Vodafone - ES

PlayBook Webworks cannot read local files

Hi,
I'm making a PlayBook webworks application. I am having problems reading a local file.
I want to make an XSLT transformation using a remote XML and a local xsl file.
I am able to download an external xml file using XMLHttpRequest, but i cannot read a local file.
I tried to read it unsing the local:/// and using relative path, but always get my XMLhttprequest status response code =0.
any ideas
Thanks in advance,
Jordi Gaset
Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: PlayBook Webworks cannot read local files

By local file do you mean one that was packaged with your app?  or one that is somewhere on the PlayBook file system?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Contributor
Posts: 6
Registered: ‎02-21-2011
My Device: Blackberry Bold 9700
My Carrier: Vodafone - ES

Re: PlayBook Webworks cannot read local files

Hi,

 

It's packaged with my App. In fact, I can show the file using  <a href="myFile.xsl">myFile</a> or <a href="local:///myFile.xsl">myFile</a>

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: PlayBook Webworks cannot read local files

Does your XHR work on a simple XML file?  I'm wondering if there may be an issue with the XSL file?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Contributor
Posts: 6
Registered: ‎02-21-2011
My Device: Blackberry Bold 9700
My Carrier: Vodafone - ES

Re: PlayBook Webworks cannot read local files

To ensure, I've tried with a plain txt file and with a plain html file, and I have the same results Smiley Sad

Developer
Posts: 669
Registered: ‎02-19-2011
My Device: BlackBerry PlayBook 32GB
My Carrier: Sprint

Re: PlayBook Webworks cannot read local files

This is most definitely broken. I'm experiencing the same issue using JQuery's $.getJSON function.

 

$.getJSON('http://domain.com/animations/bootscreen.json', function(json) {

 

/* THIS WORKS FINE */

 

});

 

 

$.getJSON('animations/bootscreen.json', function(json) {

 

/* THIS DOES NOT WORK */

 

});

 

 

Staff UI Prototyper (read: full-time hacker)


My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App

Developer
Posts: 669
Registered: ‎02-19-2011
My Device: BlackBerry PlayBook 32GB
My Carrier: Sprint

Re: PlayBook Webworks cannot read local files

A really important question here is:

 

When is this going to get fixed?

 

If it's not fixed soon I'm going to have to change my application to fetch it's local data in another way. The AJAX way is more elegant but at the moment it's broken in a very show-stopping way.

 

I want to submit my app well before the 15th because of the free PlayBook promotion. In fact my app would be ready to go if it weren't for this issue.

 

RIM?

Staff UI Prototyper (read: full-time hacker)


My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App

Developer
Posts: 669
Registered: ‎02-19-2011
My Device: BlackBerry PlayBook 32GB
My Carrier: Sprint

Re: PlayBook Webworks cannot read local files

I have added this issue to the Developer Zone Issue Tracker.

Staff UI Prototyper (read: full-time hacker)


My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App

Contributor
Posts: 17
Registered: ‎02-18-2011
My Device: Not Specified

Re: PlayBook Webworks cannot read local files

Ok since I hate waiting, I created a workaround. It works for me and maybe it will for others as well which is why I post it.

 

In my case I wanted to load local JSON files through XHR. Since this doesn't work at the moment I did the following:

 

change the json files slightly so they can be interpreted as javascript without causing errors.

 

So what used to be JSON like this in the files:

 

{"key" : "value", "key" : "value"}

 

is now for the time being:

 

mystuff = {"key" : "value", "key" : "value"};

 

I have this function:

 

 

function loadNode(file, callback) {
  var scriptnode;
  if(document.getElementById('myscriptnode')) {
  document.getElementsByTagName('head')[0].removeChild(document.getElementById('myscriptnode'));
  }
  scriptnode = document.createElement('script');
  scriptnode.setAttribute('type', 'text/javascript');
  scriptnode.setAttribute('id', 'myscriptnode');
  scriptnode.setAttribute('src', file);
  document.getElementsByTagName('head')[0].appendChild(scriptnode);
  scriptnode.onload = callback;
};

 

 

Now, elsewhere in my code I can do stuff like:

 

loadNode('datafiles/somefile.js', function(){

 // do things with whatever is now in the global variable mystuff

});

 

loadNode will load my data and execute the callback when the data has finished loading. It will also keep overwriting the created script node in order to prevent clogging up the DOM.

 

Not the prettiest thing maybe but hey, it works!

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: PlayBook Webworks cannot read local files

I have sent this to the Development and Testing teams to take a look at.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter