Package com.ebasetech.xi.services
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 methodgetCandidateAddresses(String)
.static java.lang.String[][]
getCandidateAddresses(java.lang.String postCode)
Returns an array of list entries forpostCode
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.InvalidPostcodeExceptionReturns an array of list entries forpostCode
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. SeeFieldList.getDisplayValues(boolean)
for more information on list values.This postcode lookup service provides a two stage user interface:
- Show the user a dropdown list of candidate addresses for a postcode using this method
- When the user makes a selection from the list, call method
getAddressConstituentParts(String)
to get the list details
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
- ifpostCode
is not a valid post codecom.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.FormRuntimeExceptionReturns an array of address details for an address id, as provided by methodgetCandidateAddresses(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
- Parameters:
addressId
- is the returned list value as provided by methodgetCandidateAddresses(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
-