Class PostcodeAnywhereServices

java.lang.Object
com.ebasetech.xi.services.PostcodeAnywhereServices
All Implemented Interfaces:
java.io.Serializable

public class PostcodeAnywhereServices
extends java.lang.Object
implements java.io.Serializable
PostcodeAnywhereServices provides static methods to access the PostcodeAnywhere service.
Since:
V4.4
See Also:
Serialized Form
  • Constructor Summary

    Constructors
    Constructor Description
    PostcodeAnywhereServices()  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String[] getAddressConstituentParts​(java.lang.String addressId)
    Returns an array of address details for an address id, as provided by method getCandidateAddresses(String).
    static java.lang.String[][] getCandidateAddresses​(java.lang.String postCode)
    Returns an array of list entries for postCode using the PostcodeAnywhere service provider.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PostcodeAnywhereServices

      public PostcodeAnywhereServices()
  • Method Details

    • getCandidateAddresses

      public static java.lang.String[][] getCandidateAddresses​(java.lang.String postCode) throws com.ebasetech.xi.exceptions.FormRuntimeException, com.ebasetech.xi.exceptions.InvalidPostcodeException
      Returns an array of list entries for postCode using the PostcodeAnywhere service provider. Each list entry consists of an array containing two Strings that correspond to the list display value and the list returned value. See FieldList.getDisplayValues(boolean) for more information on list values.

      This postcode lookup service provides a two stage user interface:

      1. Show the user a dropdown list of candidate addresses for a postcode using this method
      2. When the user makes a selection from the list, call method getAddressConstituentParts(String) to get the list details
      A valid licence for the PostcodeAnywhere service must be installed.

      Javascript example:

       try
       {
         var addresses = PostcodeAnywhereServices.getCandidateAddresses(postcode);
         if (addresses.length == 0)
         {
           event.owner.addErrorMessage("Invalid postcode. Please enter a valid postcode");
         }
         else
         {
           var list = fields.ADDRESSES.createCustomList();
           for each (var address in addresses)
           {
             list.add(address[0], address[1]);
           }
           fields.ADDRESSES.fieldControl.show();
         }
       }
       catch (e)
       {
         event.owner.addErrorMessage(e.javaException.message);
       }
       
      Parameters:
      postCode - post code
      Returns:
      a list of candidate addresses
      Throws:
      com.ebasetech.xi.exceptions.InvalidPostcodeException - if postCode is not a valid post code
      com.ebasetech.xi.exceptions.FormRuntimeException - if any other error occurs e.g. unable to access the PostcodeAnywhere remote Url
      Since:
      V4.4
      See Also:
      getAddressConstituentParts(String)
    • getAddressConstituentParts

      public static java.lang.String[] getAddressConstituentParts​(java.lang.String addressId) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Returns an array of address details for an address id, as provided by method getCandidateAddresses(String). In the UK, the address details consists of an array of Strings as follows:
      • organisation name
      • address line 1
      • address line 2
      • address line 3
      • town
      • county
      See PostcodeAnywhere documentation for other countries.
      Parameters:
      addressId - is the returned list value as provided by method getCandidateAddresses(String)
      Returns:
      array of address details
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs e.g. unable to access the PostcodeAnywhere remote Url