XWeb: IndividualAddress HTML Form Enter ColdFusion Sample 1

ColdFusion makes it very easy to integrate with web services. One of the most common requirements an organization has is the need to insert and update a variety of member information. Most often, this includes individual's addresses, phone numbers, fax numbers, and e-mail addresses.

The code provided below is an example of how HTML, ColdFusion, and xWeb can be used to Enter an individual's address information.

Assumptions

In order to use the code provided below, you will need to have successfully implemented the various web methods using the required core ColdFusion component for xWeb.

The Individual Address form has a couple drop down dependencies. The code below assumes there are two queries defined in the application scope: qrySelectState and qrySelectCountry.

Sample Code

<!--- process submitted form --->
<cfif ISDEFINED("btn_enter")>
<cfsavecontent variable="adrXML">
<cfoutput>
<ns:AddressObjects>
<ns:AddressObject>
<ns:cxa_cst_key>#form.cst_key#</ns:cxa_cst_key>
<ns:adr_line1>#trim(form.adr_line1)#</ns:adr_line1>
<ns:adr_line2>#trim(form.adr_line2)#</ns:adr_line2>
<ns:adr_line3>#trim(form.adr_line3)#</ns:adr_line3>
<ns:adr_city>#trim(form.adr_city)#</ns:adr_city>
<ns:adr_state>#trim(form.adr_state)#</ns:adr_state>
<ns:adr_post_code>#trim(form.adr_post_code)#</ns:adr_post_code>
<ns:adr_county>#trim(form.adr_county)#</ns:adr_county>
<ns:adr_latitude>#trim(form.adr_latitude)#</ns:adr_latitude>
<ns:adr_longitude>#trim(form.adr_longitude)#</ns:adr_longitude>
<ns:adr_add_date>#nfws_change_date#</ns:adr_add_date>
<ns:adr_add_user>#nfws_change_user#</ns:adr_add_user>
<ns:cxa_adt_key>#form.cxa_adt_key#</ns:cxa_adt_key>
</ns:AddressObject>
</ns:AddressObjects>
</cfoutput>
</cfsavecontent>
<cfinvoke component="/gateway/netforum_xweb" method="xweb_InsertFacadeObject" returnvariable="adrXML">
<cfinvokeargument name="nfws_namespace" value="#application.nfws_namespace#" omit="no">
<cfinvokeargument name="nfws_address" value="#application.nfws_address#" omit="no">
<cfinvokeargument name="nfws_token" value="#session.nfws_token#" omit="no">
<cfinvokeargument name="szObjectName" value="IndividualAddress" omit="no">
<cfinvokeargument name="oNode" value="#adrXML#" omit="no">
</cfinvoke>
<script language="javascript" type="text/javascript">
alert('Request Completed.\nClick OK to continue.');
var oParent = window.opener;
oParent.location.reload();
window.close();
</script>
<cfabort>
</cfif>
 
<!--- xweb_Authenticate : Initialize --->
<cftry>
<cfinvoke component="/gateway/netforum_xweb" method="xweb_Authenticate" returnvariable="nfws_token">
<cfinvokeargument name="uname" value="#application.nfws_uname#" omit="no">
<cfinvokeargument name="pword" value="#application.nfws_pword#" omit="no">
</cfinvoke>
<!--- xweb_GetFacadeObject : Customer --->
<cfinvoke component="/gateway/netforum_xweb" method="xweb_GetFacadeObject" returnvariable="qryCustomerPrimary">
<cfinvokeargument name="nfws_namespace" value="#application.nfws_namespace#" omit="no">
<cfinvokeargument name="nfws_address" value="#application.nfws_address#" omit="no">
<cfinvokeargument name="nfws_token" value="#session.nfws_token#" omit="no">
<cfinvokeargument name="szObjectName" value="Customer" omit="no">
<cfinvokeargument name="szObjectKey" value="#session.cst_key#" omit="no">
</cfinvoke>
<cfquery name="qryGetAddressCategories" datasource="#nfdatabase#">
SELECT adt_key,
adt_code
FROM co_address_type (nolock)
WHERE adt_key NOT IN
(
SELECT cxa_adt_key
FROM co_customer_x_address
WHERE cxa_cst_key = '#session.cst_key#'
AND cxa_delete_flag = 0
)
AND adt_delete_flag = 0
ORDER BY adt_code
</cfquery>
<cfcatch type="any">
<h4>Unable to connect to the web service gateway.</h4>
<cfflush>
<cfabort>
</cfcatch>
</cftry>
 
<!--- Display Form --->
<div style="width:600px; background-color:white;">
<br />
<cfform action="#cgi.script_name#" method="post" id="upd">
<cfoutput query="qryCustomerPrimary">
<strong>#cst_name_cp#</strong>:<br />
<br />
<div style="margin:0px; padding:10px; border:1px black solid;">
<table>
<tr><td colspan="3">
Address Line 1:<br />
<cfinput type="text" name="adr_line1" value="" size="50" required="yes" message="Address Line 1 is required"><br />
</td></tr>
 
<tr><td colspan="3">
Address Line 2:<br />
<cfinput type="text" name="adr_line2" value="" size="50" required="no"><br />
</td></tr>
 
<tr><td colspan="3">
Address Line 3:<br />
<cfinput type="text" name="adr_line3" value="" size="50" required="no"><br />
</td></tr>
 
<tr><td valign="top">
City:<br />
<cfinput type="text" name="adr_city" value="" size="50" required="yes" message="City is required"><br />
</td><td valign="top">
State:<br />
<cfselect id="adr_state" name="adr_state">
<cfparam name="statefieldname" default="state">
<option value="">- select one -</option>
<cfloop query="application.qrySelectState">
<cfif trim(value) IS NOT "">
<option value="#value#">#display#</option>
</cfif>
</cfloop>
</cfselect><br />
</td><td valign="top">
Post Code:<br />
<cfinput type="text" name="adr_post_code" value="" size="15" required="yes" message="Post Code is required"><br />
</td></tr>
 
<tr><td valign="top">
County:<br />
<cfinput type="text" name="adr_county" value="" size="30" required="no"><br />
</td><td colspan="3" valign="top">
Country:<br />
<cfselect id="adr_country" name="adr_country" disabled="disabled">
<cfparam name="countryfieldname" default="country">
<option value="United States">United States</option>
<option value="">- select one -</option>
<cfloop query="application.qrySelectCountry">
<cfif trim(value) IS NOT "">
<option value="#value#">#display#</option>
</cfif>
</cfloop>
</cfselect><br />
</td></tr>
</table>
 
<table>
<tr><td valign="top">
Laitude:<br />
<cfinput type="text" name="adr_latitude" value="" size="25"><br />
</td><td valign="top">
Longitude:<br />
<cfinput type="text" name="adr_longitude" value="" size="25"><br />
</td><td>
Type:<br />
<cfselect name="cxa_adt_key">
<option value="">-- select one --</option>
<cfloop query="qryGetAddressCategories">
<option value="#adt_key#">#adt_code#</option>
</cfloop>
</cfselect><br />
</td></tr>
</table>
 
<br />
 
<table width="100%">
<tr><td colspan="3" align="right">
<cfinput type="hidden" name="cst_key" value="#trim(cst_key)#" />
<cfinput type="submit" name="btn_enter" value="ENTER" />
<cfinput type="reset" name="btn_reset" value="RESET" />
<cfinput type="button" name="btn_close" value="CLOSE" onclick="var oParent = window.opener; oParent.location.reload(); window.close();" />
</td></tr>
</table>
</cfoutput>
<br />
</cfform>
</div>