• Welcome to KonaKart Community Forum. Please login or sign up.
 

[Server Engine] getCountries parameters

Started by David, October 03, 2007, 03:51:02 pm

Previous topic - Next topic

David

Hi again!!

I have another doubt, now with the parameters of getCountries() function on KKAdminIf. This is the API:

QuotegetCountries

AdminCountrySearchResult getCountries(AdminCountrySearch search,
                                      int offset,
                                      int size)
                                      throws KKAdminException

    This returns an AdminCountrySearchResult object.

    Parameters:
        search -
        offset - the offset in the db
        size - the number of records from the specified offset
    Returns:
        Returns an AdminCountrySearchResult object
    Throws:
        KKAdminException


I fill the AdminCountrySearch with one parameter, in this case TwoLetterCode("ES") but I don't know what are the offset and the size of that call. I tried with 0, 1, the lenght of the countries list....but I never got anything on the results array. ¿I'm doing something wrong?

trevor

David,

Offset 0 and size 1 is fine (these are normally used for paging through record sets, get 'size' records from offset 'offset').

You have made a small error that a few others have made - it's not obvious.  When you create an AdminCountrySearch object from the classes generated from WSDL - you don't get the luxury of the default initialisation of certain fields (as you would if you instantiate the version of AdminCountrySearch in the konakartadmin.jar).

The result is that the Id field is set to 0.  This means you're asking to search for country with id = 0.

You have to explicitly tell it not to use the Id field by setting it to -1 as follows:


        AdminCountrySearch search = new AdminCountrySearch();
        search.setTwoLetterCode("ES");
        search.setId(-1);                  // KonakartAdminConstants.NOT_SET = -1
       
        int offset = 0;
        int size = 1;
       
        AdminCountrySearchResult result = eng.getCountries(search, offset, size);


All the best,
Trevor

David

a lot of thanks Trevor, I tried a lot of combinations before asking here, but now it seems easier than I thought

Regars

trevor

You're welcome David.  It's good to get questions like this in the forum as the answers can be useful to others.
Trevor.