Extended Array Types

Create your component

Add the following to array property to the component you wish to extend:

<cfproperty type="array" name="arraytest" arrayProps="fieldname_1:fielddatatype_1;fieldname_2:fielddatatype_2;etc;" required="true" />

Notice the additional attribute arrayProps that allows you to specify the extended column data types.

eg. myComponent.cfc
<cfcomponent 
  name="myComponent" 
  output="false" 
  extends="farcry.farcry_core.packages.types.types"
  hint="Test component to ensure that the fourq persistence layer works correctly.">

<cfproperty type="string" name="normal_field" default="normal_value" required="true" />
<cfproperty type="array" name="arraytest" arrayProps="fname:string;lname:string;age:numeric;" required="true" />

</cfcomponent>

And save in the custom types directory [client directory]/packages/types

To deploy the object:

  1. go to FarCry Admin
  2. coAPI management
  3. Types classes
  4. Click 'Deploy' next to your custom type

Two tables should be created in the database:

  1. myComponent
  2. myComponent_arraytest

The myComponent_arraytest table will have the fields

  • data
  • seq
  • objectid
  • ... any additional field you specify

Create/Set up the custom edit handler just like for other custom types. The new edit forms should allow the the ability to add additional information to the array as a structure

To update the additional information of the array items, the array must be and array of structure

The figure below dump shows how the array is to be prepped before calling the setData() function

TODO: SAMPLE DUMP TO BE INSERTED

eg. edit.cfm
<!--- create the instance of the object --->
<cfset myObject = CreateObject("component","#application.types\[stObj.typename\].typepath#")>

<cfset stObj_before_update = StructCopy(stObj)>

<cfdump var="#stObj_before_update#" label="BEFORE SETDATA">

<!--- prep the extended array attribute with additional information into a array of struct --->
 <cfset stObj.aInformation\[1\] = StructNew()>
 <cfset stObj.aInformation\[1\].age = 1>
 <cfset stObj.aInformation\[1\].objectid = stObj.objectid>
 <cfset stObj.aInformation\[1\].data = "DATA:UUID">
 <cfset stObj.aInformation\[1\].fname = "related info: fname">
 <cfset stObj.aInformation\[1\].lname = "related info: lname">
 <cfdump var="#stObj#" label="stObj WITH PREP PROPERTIE">

<cfset myObject.setData(stObj)>

<!---
 retrieve back the updated information note the bFullArrayProps=1 attribute this will return all the array information
 else omitted it will only return the data as an array
 --->

<cfset stObj_after_update = myObject.getData(objectid=stObj.objectid,bFullArrayProps=1)>

The below image show the data retrieved with the bFullArrayProps = 1

<cfdump var="#stObj_after_update#" label="AFTER SETDATA">