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

Native Development

Reply
Highlighted
Developer
Posts: 176
Registered: ‎11-06-2008
My Device: Not Specified
Accepted Solution

QUrl and HTTP Communication sample

I've seen the other threads about problems with the HTTP communication sample from https://developer.blackberry.com/cascades/documentation/device_comm/networking/tutorial_http_comm.ht...

 

But this issue is different. I changed the url to use HTTPS and the file downloads properly, I even output the response contents to the debug logger and it's as expected. I've even verified the file is written to the application's data folder properly as a file namedmodel.xml.

 

What I have a problem with is the attempt to load the saved file into an XmlDataModel using the sample code

 

// Create the data model using the contents of the file. The
// location of the file is relative to the assets directory.
XmlDataModel *dataModel = new XmlDataModel();
dataModel->setSource(QUrl("../../../data/model.xml"));

 

In the debug log this always throws out a message saying it could not load "../../../data/model.xml"

 

After finding no answers in the forums I tried changing the path used to access this file and changed the code to

 

XmlDataModel *dataModel = new XmlDataModel();
dataModel->setSource(QUrl::fromLocalFile(QDir::homePath() + "/model.xml"));

 

Now this works because QDir::homePath() returns the path to the app's data folder. But why did it not work before using the relative path as the comments in the sample suggest? Has something changed? I see nothing in the Beta 3 release notes about this being a known issue. Any feedback is appreciated.

 

Developer
Posts: 671
Registered: ‎03-21-2012
My Device: BlackBerry PlayBook 16GB
My Carrier: Vip

Re: QUrl and HTTP Communication sample

[ Edited ]
Developer
Posts: 176
Registered: ‎11-06-2008
My Device: Not Specified

Re: QUrl and HTTP Communication sample

Thank you borceg, just like in the thread you pointed out it looks like we'll have to stick with using absolute paths.

New Member
Posts: 3
Registered: ‎10-03-2012
My Device: Alpha Device
My Carrier: Fido

Re: QUrl and HTTP Communication sample

I was having a similar problem too. Thanks for the solution.

New Developer
Posts: 129
Registered: ‎10-03-2012
My Device: Blackberry Alpha

Re: QUrl and HTTP Communication sample

+1
Click the Like button if you find my post useful and as a way to let me know someone actually read it.