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
Trusted Contributor
Posts: 114
Registered: ‎05-09-2013
My Device: BB10 Z10
My Carrier: Virgin

Re: Access to app's working directory

haha I'm heading that way soon!

 

Yes it definitely has data.

 

The WebView component I'm using now looks like this:

 

                WebView {
                    url: "local:///assets/charts/BPPlot.htm?filePath=" + "../../../../data/" + "data.xml"
                    settings.zoomToFitEnabled: true
                    settings.background: Color.Yellow
                    horizontalAlignment: HorizontalAlignment.Fill
                    settings.defaultFontSize: 5
                    settings.minimumFontSize: 5
                    settings.devicePixelRatio: 1.0
                    settings.viewport: {
                        "width": 1280,
                        "height": 500
                    }

 My QML is definitely in "assets", not in subdir...Counting from "assets" backwards, the directory structure is 4 levels deep... then, one into "data", and I should be there, right?

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Access to app's working directory

Okay the WebView won't be working because it is probably being invoked as a card. As this is effectively a seperate program it won't have access to your app folders.

 

Try writing the xml file to a shared folder and see if that works.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Trusted Contributor
Posts: 114
Registered: ‎05-09-2013
My Device: BB10 Z10
My Carrier: Virgin

Re: Access to app's working directory

No, I'm invoking it as a Dialog:

Dialog {
    Container {
        Container {
            Container {
                WebView {
...

 the reason for 3 containers is that I have other UI elements around it Smiley Happy ... but as such, WebView works fine with the local data XML...

 

Let me see if I can save in shared...

 

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Access to app's working directory

To be honest I thought you were updating the ajax function not the WebView.

 

Never mind, this is what is confusing me, either data and assets shouldn't work because the system effectively hides that fact that WebView is invoking the web browser as a card from the developer and in that case both folders should be inaccessible or it's not invoking and they should both work!

 

The fact that one folder works and the otherone doesn't (now that we've ruled out everything but the path) is weird to say the least.

 

Sorry I haven't really been very useful try the shared folder and let me know the results.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Access to app's working directory

@zmey if you're reading, fresh eyes on this one may help as well?


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Trusted Contributor
Posts: 114
Registered: ‎05-09-2013
My Device: BB10 Z10
My Carrier: Virgin

Re: Access to app's working directory

I've been actually trying all your suggestions on both levels, Ajax and WebView. I even tried 5 levels of "../" for the Ajax, since the HTML page is in a subfolder of "assets" (one level deeper than QML)

 

Yes - the fact one folder works an the other doesn't is confusing me too... But thanks for your help in any case!

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Access to app's working directory

[ Edited ]

Okay well in the silence I've written a test app and can verify this behaviour, no access to data via a relative route.

There is also another thread almost identical to yours which verifies this as well, unfortunately with no solution.

 

http://supportforums.blackberry.com/t5/Native-Development/Access-to-the-data-folder-in-javascript/td...

 

[Edit] Oh and he used 3 '..'s. Smiley Wink

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Access to app's working directory

[ Edited ]

A full pathname works though...

 

		WebView {
		    verticalAlignment: VerticalAlignment.Center
		    horizontalAlignment: HorizontalAlignment.Center
		    preferredHeight: 600
		    preferredWidth: 400
            url: "file:///accounts/1000/appdata/biz.stok.stokCookbook.testDev_tokCookbook89430b84/data/webpage.htm"
		}

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Trusted Contributor
Posts: 114
Registered: ‎05-09-2013
My Device: BB10 Z10
My Carrier: Virgin

Re: Access to app's working directory

Oh wow, yes, almomst identical. So - I may have to resort to saving a copy of my file into a more accessible folder... and fetching it from there... Thanks for the help, at least I am not chasing a wild goose! Smiley Very Happy

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Access to app's working directory

[ Edited ]

Check above, fully qualifying the path should work (it does in my test app).

 

If it does from there it should be fairly simple to check it's getting through your js function intact.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.