This article explains how to add a paginating system for hotel list results using the
Use a List or an Array to save the
cacheKey and a List or an Array to save the
For example, you have made the first list request, and you received the response for the first page, which also includes the
cacheLocation for the second page.
Make two lists in which you will save the
cacheKeyList= new ArrayList<String>();
cacheKey); // where
cacheKeyis being received in the Hotel List response and is used for requesting the next page
cacheLocationList= new ArrayList<String>();
cacheLocation); // where
cacheLocationis being received in the Hotel List response and is used for requesting the next page
cacheLocationList in your next Hotel List request, you will receive the response for page 2.
Now, for every request that you do, the cache keys and cache locations for every page are being stored in your list, and for example, if you are at page 5 and you want to go at page 3, all you have to do is make a request using
Also, the lists should be reinitialized after about 30 minutes, as the
cacheLocation will expire.
In addition to the above example, you will have to shorten the list to the size of the current page you're on because once you use the cache key and the cache location for a previous page than the one you're on, the new cache key and cache location that you will receive for the next page will be different from the one you had for that next page. For example:
You are on page 5 and you saved the
cacheLocation for page 6 in
cacheLocation. You go to the previous page, which is page 4 using
cacheLocation. You now have to delete all the records from the lists that are past  (3rd record in the list) before receiving the response of page 4. For example
cacheLocation should not exist at this very moment. After this has been done, you will receive the response with page 4 of hotels and the
cacheLocation for page 5, which will be added to
In order to get to the first page, you have to make the initial request, without the
Initial request without
cacheLocation- used to request page 1 of hotels
cacheLocation- used to request page 2 of hotels
cacheLocation- used to request page 3 of hotels
cacheLocation- used to request page 4 of hotels
cacheLocation[n]- used to request page n+2 of hotels
Please note that the example provided is written in Java and depending on the developing language you are using, this may not work. This should be used as a reference and not copy/pasted in your application.