Saturday, February 8, 2014

A reusable Canadian address builder/validator widget (2)

The configuration

AddrBdr  configuration defines fields binding to the host page context and data/operation bindings to the backend WCF service, as well as customizable messages on the UI. Following code snippet is self-explaining about the configuration entries.




 Integrate with address hosting page

The major consideration is to minimize code change on the address hosting page while applying AddrBdr, i.e. to use “unobtrusive” javascript pattern. This reduces complexity and minimize testing effort no matter in case it is to apply AddrBdr to a new page or in case to plug-in to an existing page.

 AddrBdr is composed with following files as per the front-end:



 The backend WCF service

AddrBdr.js module requires following operation and data contracts:

 Multiple addresses support

A web page can have multiple sets of address fields, e.g. billing address, mailing address, etc. AddrBdr has a configuration entry AddrSets where multiple sets of addresses are specified. AddrBdr is then able to bind the logic and data into an address set when it becomes active.

Disable auto-correct

In some occasions the user could desire formatting an address in a specific way, may that be required by clients, or experience a new address that happens to be not yet in Canada Post published address db.  AddrBdr is facilitated with a checkbox for turning off auto-correct feature. But in that case the accepted address will be marked as “manual” in verification status.

No comments: