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
Regular Contributor
Posts: 58
Registered: ‎01-19-2011
My Device: 9800
My Carrier: vodafone
Accepted Solution

Store and open remote aspx file on device

[ Edited ]

Hi.

 

 

 

Im developing a widget that opens a remote webfilehttp://11.11.11.11/myHtmlPage.aspx. I need it to be available offline as well so i though i would save the html file on my SDCard.

 

 

 

My question is. How do I save the file with all its html and how do I open it so it opens as a webpage.

 

 

 

Here is a code snippet of what doesnt really work. (it opens the file stored on the sd card all right but with the text http://11.11.11.11/myHtmlPage.aspx instead of the html which was in the original file

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

var

 

 

filePath = file:///SDCard/myDataFile.html;

 

function 

openFile() {

blackberry.io.file.readFile(filePath, readFile);

 }

 

function 

saveFile() {

var blob = blackberry.utils.stringToBlob('http://11.11.11.11/myHtmlPage.aspx');"file saved");

blackberry.io.file.saveFile(filePath, blob);

 

 

}

 

Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Store and open remote aspx file on device

I think the problem lies in the following snippet:

 

 

var blob = blackberry.utils.stringToBlob('http://11.11.11.11/myHtmlPage.aspx');"file saved");

 

 

stringToBlob does not make an HTTP request to the value that you provide it.  It turns whatever string object that is received into a Blob object.

 

You will need to use XmlHttpRequst to make a Web request to the given page, and then use the results of that HTTP response in the call to the stringToBlob method.

 

Does that make more sense?

 

Cheers!

Adam

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.