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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 10
Registered: ‎01-16-2013
My Device: BB7 and BB10
My Carrier: Airtel

Multiple Image caching webworks10/bbui.js

Hi folks,

 

I am developing an app using Blackberry webworks 10 for Phone along with bbui.js.

 

I have a list of cities. On click of each city I list few images from the webservice.

 

My problem is each time I click on the same city it downloads from the webservice which takes some time.

 

Is there any particular way of caching the images where in the next time I click on the same city it can load the images real quick?

 

What is the right way to achieve this?

 

Any help would be really appreciated.

 

Thanks in advance.

Highlighted
Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Multiple Image caching webworks10/bbui.js

Easiest way to cache images is to create a JavaScript variable that is an image object..  Typically this is called Pre-fetching.

 

As long as your JS variable stays in scope, the image should remain in the cache.  However, you'll want to ensure you clean up your variables once you are done otherwise it will grow the memory usage.  Usually setting the variable to null will clean it up.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 10
Registered: ‎01-16-2013
My Device: BB7 and BB10
My Carrier: Airtel

Re: Multiple Image caching webworks10/bbui.js

Thanks Neil,

 

But I have a problem here.

 

In screen A for ex. I list few cities say some 50 cities.

 

In screen B depending on the city selected in screen A(city is passed as a query string)

http://ipadd/Test/DataSync.svc/JSON/Properties/city

 

I display the images along with data related to that particular image from the response.

 

How would I pefetch in this scenario?

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Multiple Image caching webworks10/bbui.js

I'm not sure I understand.  As long as you have a URL you should be able to pre-fetch.

 

Can you explain your scenario further?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 10
Registered: ‎01-16-2013
My Device: BB7 and BB10
My Carrier: Airtel

Re: Multiple Image caching webworks10/bbui.js

Neil,

 

Let  me explain the scenario from the begining.

 

I have screen A. In screen A I make an ajax call

 

http://ipadd/Wcf/DataSync.svc/JSON/cities

 

I display the cities obtained from the response on Screen A. ex: Chicago, Dallas, SanDiego......


Now onclick of any one particular city, Screen B is displayed.

 

In screen B again I make an ajax call :

 

http://ipadd/Wcf/DataSync.svc/JSON/properties?city

 

Depending on the response I dispaly the images .

 

The problem is, as I am dispalying n number of images in screen B it is taking lot of time. I want to get rid of this issue.

 

You mentioned to prefetch but how would I know which city will be selected by the user in screen A?

 

Probably I can prefetch Screen A as it will result in  the same data always i.e by default it will just display the cities.

 

I hope I am clear now.

 

Please help me out.

 

I also wanted to understand that is there any option  to use dropdown of BBui.js as an autocomplete to search from the dropdown list?

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Multiple Image caching webworks10/bbui.js

There isn't a dropdown autocomplete in bbUI.js

 

In your situation you're not going to likely know which one the user is picking..

 

The only savings you could do is when they view screen B pre-fetch the images so that if they go back and then into screen B again they are cached.

 

Although this could also be handled by setting the cache headers on the images and wouldn't require client side coding.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter