public class PostcodeAnywhereServices
extends java.lang.Object
implements java.io.Serializable
PostcodeAnywhereServices
provides static methods to access the PostcodeAnywhere service.Constructor and Description |
---|
PostcodeAnywhereServices() |
Modifier and Type | Method and 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. |
public static java.lang.String[][] getCandidateAddresses(java.lang.String postCode) throws com.ebasetech.xi.exceptions.FormRuntimeException, com.ebasetech.xi.exceptions.InvalidPostcodeException
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:
getAddressConstituentParts(String)
to get the list detailsJavascript 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); }
postCode
- post codecom.ebasetech.xi.exceptions.InvalidPostcodeException
- if postCode
is not a valid post codecom.ebasetech.xi.exceptions.FormRuntimeException
- if any other error occurs e.g. unable to access the PostcodeAnywhere remote UrlgetAddressConstituentParts(String)
public static java.lang.String[] getAddressConstituentParts(java.lang.String addressId) throws com.ebasetech.xi.exceptions.FormRuntimeException
getCandidateAddresses(String)
.
In the UK, the address details consists of an array of Strings as follows:
addressId
- is the returned list value as provided by method getCandidateAddresses(String)
com.ebasetech.xi.exceptions.FormRuntimeException
- if any error occurs e.g. unable to access the PostcodeAnywhere remote Url