0

I am trying to make dynamically generated html 5 graphs show up in a webview in Blackberry 10 Cascades. I have confirmed the html5 that I have generated, draws the correct graphs. My problem is that when I try to implement this in the Blackberry 10 Cascades Beta 3 SDK (using the Blackberry 10 Dev Alpha Simulator), the webview that is supposed to show the graph, just looks like this:

Error: This file could not be opened. Check that you have the correct permissions and try again.

Here is the code that leads to this error:

//html_ already contains the html-5 code to make the graph at this point in the code

//This is the file path to a local file that is actually accessable in the emulator
//and not just from Windows
//
QFile *chartFile = new QFile("app/native/assets/data/chart.html");

if (chartFile->open(QIODevice::WriteOnly)) {
    chartFile->write(html_.toUtf8());
    chartFile->flush();
    chartFile->close();
}

if (chartFile) delete chartFile;

if (graphView_) {
    graphView_->setHtml("");
    graphView_->setUrl(QUrl::fromLocalFile("app/native/assets/data/chart.html"));
}

I checked the permissions of that file, put they are all Allow (777 permissions for those who know Unix style permissions).

I added access_internet to the bar-descriptor.xml, eventhough my app was already able to access remote sites, just to see if that would fix it, but it did not.

I've been searching around trying to find a solution to this problem, but I have not.

If anyone could help me out with this, it would be greatly appreciated.

-------------------------------------------------------


Update:

I changed the code to set the html directly, now I have this:

if (graphView_) {
    graphView_->setHtml(html_, QUrl("app/native/assets/data/chart.html"));
}

But nothing shows. It seems I have the wrong relative path relative to my base url.

My base url is this: QUrl("app/native/assets/data/chart.html")

My relative paths all begin with: ./Highcharts/js/...

My relative paths are located under: app/native/assets/data/Highcharts/js

It seems to me that I this should work, but when I do this, I just a blank screen, as if it can not find my relative paths. So I don't know what's going on here either.

user1296259
  • 521
  • 1
  • 13
  • 33
  • Have you tried setting the html directly instead of writing it to a file? Have you tried rendering a file that already existed in the directory instead of one that you have generated? – phyatt Nov 27 '12 at 20:44
  • The problem with setting the html directly is that I am using a third party javascript library to generate the html-5 graph, and that javascript has to be referenced with a relative path. But if I set the html directly, I do not know where to make that path relative to. Would anyone know the answer to that? That file, chart.html, already did exists in that directory. I did not generate it at runtime. – user1296259 Nov 27 '12 at 20:55
  • Ok - I disovered you can set the base url for relative paths, but now I just get a blank screen, as if my relative paths are not the correct paths relative to the base url I set. – user1296259 Nov 27 '12 at 21:32
  • When referencing local files, you can tell it to look for other files in its same directory (that the html file is in) using `./` or to go up a directory with `../` and `/` specifies the root of the domain. – phyatt Nov 27 '12 at 21:33
  • But I can't seem to make it work - Even when I set the base url to the same directory where my html references, and I use ./ in the html, it does not work. – user1296259 Nov 28 '12 at 17:12
  • I haven't used Qt outside of the desktop, but in general, using it here would be to take advantage of the QtWebKit and it's rendering of web pages. Normally javascript is enabled on web browsers, but you could do some tests to see if it can on the Blackberry. [javascript test enable google search](https://www.google.com/search?q=javascript+test+enable) – phyatt Nov 28 '12 at 18:11
  • Thankyou, I have to look into QtWebKit - and see if I can find how to use it for Blackberry Cascades. As for Javascript, I've already seen that it does work on the Blackberry. – user1296259 Nov 28 '12 at 18:53
  • But I get unresolved inclusion when I put #include – user1296259 Nov 28 '12 at 19:00

1 Answers1

2

I found a solution that works. I'm using the first approach, not the updated approach, but instead of

graphView_->setUrl(QUrl("app/native/assets/data/chart.html"));

I'm using:

graphView_->setUrl(QUrl("local:///assets/data/chart.html"));

And I have left the rest of the code the same, and it works.

user1296259
  • 521
  • 1
  • 13
  • 33
  • This is not working for me. Did you create a "data" folder or is that part of the url? Where are you files located in respect to the url? – zezba9000 Aug 30 '14 at 06:51