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

Java Development

Reply
Trusted Contributor
foufou
Posts: 109
Registered: ‎11-15-2011
My Device: blackberry 9800
My Carrier: beginner developer

get web ressources from url

Hi,

How can I get all ressources web from url without display the web page 

i.e I have page test.html contain in the code source page.css, pic.png, file.js

How can I get all this files without display the page just from the url http://.............test.html

thanks

Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: get web resources from url

If I understand your question correctly, you want to download the 'source' of an HTML page, and then also download yourself all the 'embedded' resources, like the CSS and image files that are referenced in the source..

 

The only way I have done this is to download the HTML file - which you can do using code like the code in htmlDemo sample, and then parser the downloaded source looking for the links and other references to external resources, then download these yourself.

 

This works but requires that you understand all the possible references that might exist in an HTML page. 

 

Alternatively you may be able to do this using a BrowserField that is not displayed on the screen.  I don't know if this will actually start the download for the page even when it is not displayed.  I suspect it will but I have not tested it..

 

Assuming this does actually download the page, then you can create a BrowserController for this, then in the

handleResourceRequest(..)

method you can decide how you want to treat the URI that the page is requesting. 

 

If you search on the forum using the keywords "BrowserField sample" you will find a few KB articles that should help you get started with this approach. 

Please use plain text.
Trusted Contributor
foufou
Posts: 109
Registered: ‎11-15-2011
My Device: blackberry 9800
My Carrier: beginner developer

Re: get web resources from url

I can use the handleResourceRequest(..) only if I use the browser field and I want to download the ressource before I displayed on browser field

Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: get web resources from url

As I said, I believe you can create a BrowserField that is not displayed. 

 

I would suggest that you create a BrowserField, and add it to a Screen and see what happens.  Do not push the screen, so the BrowserField will never therefore be seen. 

 

So the BrowserField is created and is on a screen - the screen is not physically displayed on the device, but perhaps that is enough for the processing to start downloading the files. 

 

OK?

Please use plain text.