Since the code has decent comments and is available above, this post will focus on an example of how to use the component in a page.
Please note that you will need an account with the USPS for this to work. Please see my previous post for links to create the account and the user guide.
Usage Notes:
- As this component contains its own form, you cannot place it inside of another form.
- Due to a lack of an action method on components, you will trigger the lookup by passing a valid USPS User code and reloading the page - when you are ready for the pop-up.
- This component uses the new mock HTTP response class and as such you won't be able to use it without Winter 13 of Salesforce.
- JQuery, JQuery UI (with lightness css), and JQuery Block UI are all used by this component but are loaded from CDN's. Please see the read me file for details.
- This component is designed to be used on the Lead object only and for the standard address fields. You will need to customize it for use with any other object and/or fields.
<c:USPS_Address LeadObject="{!CurrentLead}" CheckFullZip="true" USPS_USERID="{!USPSUserIDCode}" />
In your page controller, declare the variable and default it to a blank string:
public string USPSUserIDCode {get; set;}
public TestController() {
USPSUserIDCode = '';
} // TestController
Then in your page controllers action function, you will need some logic like this to trigger the lookup:
USPSUserIDCode = 'INSERTYOURIDHERE';
return null;
The method should be a page refrerence return type. When the variable is set and the page gets re-rendered, the pop-up will appear and look something like this:Note that the rest of the page will be blocked until the pop-up dialog has been addressed.