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
Developer
Posts: 53
Registered: ‎10-02-2009
My Device: BlackBerry Tour 9630
My Carrier: Verizon

Data Bundling from Web Service Question

I have a BlackBerry application that retrieves data from a server based on data that is submitted by the user.  The results that are returned can be anywhere from 0-2000 results which are displayed on the device in list format.  Can someone point me in the right direction as to how I can control the number of results that come back and provide the user the ability to select "Get More" if they need to?  So in other words, how do I bundle the results and bring them back to the device in chunks?

 

Thanks in advance!

Developer
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: Data Bundling from Web Service Question

I could show you how to do this in ASP.NET/C#, but I'm afraid I'm not sure how to accomplish this on the BlackBerry... or in Java, for that matter. Theoretically you could store the results as a vector in the runtime/persistent store, and then access the records by index.

 

 

pseudo code:

class MyClass
{
  int _index = 0;
  int PAGE_SIZE = 10;
  Vector _thisPage = new Vector (PAGE_SIZE);
  
  public static void main (string [] args)
  {
    retrieve data, store
    
  }
  
  public void getPage (int index, pageSize)
  {
    for (int count = index; count < index + pageSize; count ++)
    {
      try
      {
        _thisPage.elementAt (count - index) = storedDate.elementAt (count);
      }
      catch (Exception e)
      {
        //Reached the end of the stored data before the page ended
        getMoreButton.Disable ();
        
        break;
      }
    }
  }
}

 

 

Hope that helps,

~Dom

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Data Bundling from Web Service Question

If you want to bring the data back in chunks, this unfortunately has very little to do with the BlackBerry and very much to do with the web service infrastructure you are using. The "chunkage" will have to be supported host side. Assuming that the server request is stateless (which is likely but not always the case), then your HTTP request will have to include something to determine the current offset for the next chunk of data.

 

 

Highlighted
Developer
Posts: 53
Registered: ‎10-02-2009
My Device: BlackBerry Tour 9630
My Carrier: Verizon

Re: Data Bundling from Web Service Question

Thanks for the responses.  I'll have to give it some thought.  The connection is stateless so I'm not sure how I would tell the server that I've downloaded x number of results already especially when the results could be anything.  The server isn't going to "remember" what result set belongs to what requester.  It almost seems like it would need to maintain a session with the server and iterate through the bundled results.

 

If anyone else can add, it would be appreciated.  Thanks everyone!