programatically add to type array

16 views
Skip to first unread message

AJ Mercer

unread,
Mar 12, 2014, 11:27:58 PM3/12/14
to farcr...@googlegroups.com
when you have something like this
<cfproperty
    name="aPowers" type="array"
    ftSeq="12" ftFieldset="Related Content" ftWizardStep="Relationships" ftLabel="Powers"
    fttype="array" ftJoin="superPower"
    hint="Array of superhuman powers." />

​How do you programatically add to 'aPowers'​?


--

AJ Mercer
<webonix:net strength="Industrial" /> | <webonix:org community="Open" />
http://twitter.com/webonix

Blair McKenzie

unread,
Mar 12, 2014, 11:57:18 PM3/12/14
to Unname
<cfset arrayappend(stObj.aPowers,stSuperPower.objectid) />
<cfset setData(stProperties=stObj) />

Blair


--
You received this message cos you are subscribed to "farcry-dev" Google group.
To post, email: farcr...@googlegroups.com
To unsubscribe, email: farcry-dev+...@googlegroups.com
For more options: http://groups.google.com/group/farcry-dev
--------------------------------
Follow us on Twitter: http://twitter.com/farcry
---
You received this message because you are subscribed to the Google Groups "farcry-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to farcry-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

AJ Mercer

unread,
Mar 13, 2014, 12:13:05 AM3/13/14
to farcr...@googlegroups.com
D'oh - that is what I had, but just released when copying code to this email I had used the same type name twice when creating objects - hence the duplicate objectID message I was getting.

Thanks for the reply Blair

AJ Mercer

unread,
Mar 13, 2014, 2:46:03 AM3/13/14
to farcr...@googlegroups.com
anyone know where I can get more info/examples on this:

Extended Arrays

Icon

Array properties can themselves be extended to include additional attributes - but lets keep it simple for now.

https://farcry.jira.com/wiki/display/FCDEV60/UNIT+06+-+Content+Relationships


AJ Mercer

unread,
Mar 13, 2014, 4:05:31 AM3/13/14
to farcr...@googlegroups.com
I have this property in AflGames.cfc
<cfproperty name="aClients" type="array" required="false" 
ftSeq="6" ftWizardStep="Requests" ftFieldset="Responces" ftLabel="Clients" 
ftType="array" ftJoin="AflGameClient">

so have created types/AflGales_aClients.cfc
<cfproperty ftseq="1" ftfieldset="General Details" 
name="preference" type="string" 
hint="prefered game." 
required="no" default=""  
ftlabel="Preference" />

and deployed changes

I can edit an AflGame and add a Client
but when I go and edit again I get

Message: Complex object types cannot be converted to simple values.

Tag Context:
\farcry\core\packages\formtools\join.cfc (line: 222)
\farcry\core\tags\wizard\object.cfm (line: 358)
\farcry\core\tags\wizard\object.cfm (line: 355)
\farcry\core\tags\wizard\object.cfm (line: 350)
\farcry\core\tags\wizard\object.cfm (line: 229)
\farcry\core\tags\wizard\object.cfm (line: 15)
\farcry\core\tags\wizard\object.cfm (line: 1)
\farcry\core\packages\types\types.cfc (line: 836)
\farcry\core\tags\navajo\edit.cfm (line: 171)
\farcry\core\webtop\edittabEdit.cfm (line: 58)

Blair McKenzie

unread,
Mar 13, 2014, 8:22:17 PM3/13/14
to Unname
The trade-off when using extended arrays is that you have to write your own UI. This is the reason the Handpicked Rule always has so many issues - it has it's own UI that isn't used or stress tested anywhere else.

If you want to be able to edit that array in a Webtop wizard you will need to provide ftEditAClients (for the UI) and ftValidateAClients (to parse posts into an array-of-structs) functions.

Blair


--

AJ Mercer

unread,
Mar 13, 2014, 8:41:39 PM3/13/14
to farcr...@googlegroups.com
Thanks Blair.

is 'ftEditAClients' a webskin as in ftEditAClients.cfm
or an attribute on cfproperty? 

AJ Mercer

unread,
Mar 13, 2014, 8:46:15 PM3/13/14
to farcr...@googlegroups.com
oh, it will be a function - no?

Blair McKenzie

unread,
Mar 13, 2014, 8:48:33 PM3/13/14
to Unname
They are functions on your type - stand ins for the formtool edit and validate functions.

Blair

AJ Mercer

unread,
Mar 13, 2014, 9:06:16 PM3/13/14
to farcr...@googlegroups.com
cool - got the wizard step displaying ARGUMENTS.stObj, as JSON ;-)

For programatially adding
it was 
    <cfset ArrayAppend(stGame.aClients, stAflGameClient.objectID)>

I guess not I need to append a struct instead of stAflGameClient.objectID?

Blair McKenzie

unread,
Mar 13, 2014, 9:26:21 PM3/13/14
to Unname
I assume you need the structs, otherwise why have an extended array? The struct structure should match the array table. I don't know if you can get away with just data and preference.

Blair

AJ Mercer

unread,
Mar 13, 2014, 9:41:51 PM3/13/14
to farcr...@googlegroups.com
you can get away with bare minimum :-)
<cfset stPref = StructNew()>
<cfset stPref['data'] = stAflGameClient.objectID >
<cfset stPref['preference'] = '2nd' >
<cfset ArrayAppend(stGame.aClients, stPref)>

AJ Mercer

unread,
Mar 13, 2014, 9:49:26 PM3/13/14
to farcr...@googlegroups.com
So I now have the wizard step displaying the data in a table.​​
The next trick is to converting it to a library picker.


Any tips?

Blair McKenzie

unread,
Mar 13, 2014, 11:33:11 PM3/13/14
to Unname
Look at the handpicked rule.


--

AJ Mercer

unread,
Mar 14, 2014, 12:04:07 AM3/14/14
to farcr...@googlegroups.com
I can not find
    cffunction name="ftEditaObjects"
for the rule

Justin Carter

unread,
Mar 14, 2014, 12:13:22 AM3/14/14
to farcr...@googlegroups.com

AJ Mercer

unread,
Mar 14, 2014, 12:37:14 AM3/14/14
to farcr...@googlegroups.com
oh yes - this got a make over recently.
I am looking at 6.1.5

AJ Mercer

unread,
Mar 14, 2014, 12:54:54 AM3/14/14
to farcr...@googlegroups.com
how do you get to the formtool properties defined in the extend array (AflGame_aClients.cfc)?

<cfproperty ftSeq="20"
name="TicketStatus" type="longchar" ftDefault="Applied" ftLabel="Status"
ftType="list" ftSelectMultiple="false" ftList="Applied,Offered,Other Game,Accepted,Tickets Sent"
" />​

Justin Carter

unread,
Mar 14, 2014, 12:58:39 AM3/14/14
to farcr...@googlegroups.com
It depends what info you need, there are a couple of methods to get content type metadata and property metadata:

--

AJ Mercer

unread,
Mar 14, 2014, 1:03:55 AM3/14/14
to farcr...@googlegroups.com
something like this
but I am not getting the extended properties

<cfloop from="1" to="#arraylen(aClients)#" index="i">
<cfset stClient.thisobject = aClients[i].data />
<cfset stClient.thistypename = aClients[i].typename /> 
<cfdump var="#stClient#" label="stClient">
<ft:object objectid="#stClient.thisobject#"  r_stFields="stFields" />
<cfdump var="#stFields#" label="stFields">
</cfloop>

Blair McKenzie

unread,
Mar 14, 2014, 1:13:12 AM3/14/14
to Unname
I'm fairly sure array types aren't in refObjects. You'll need to pass the entire struct into ft:object with the stObject attribute.

Blair

AJ Mercer

unread,
Mar 14, 2014, 1:20:50 AM3/14/14
to farcr...@googlegroups.com
I don't think I have the right struct here??

<ft:object stObject="#aClients[i]#"  r_stFields="stFields" />
aClients[i] - struct
CREATEDBY [empty string]
DATA 5E24E1C0-AB22-11E3-AC3B005056830008
DATETIMECREATED [empty string]
DATETIMELASTUPDATED [empty string]
LABEL [empty string]
LASTUPDATEDBY [empty string]
LOCKED 0
LOCKEDBY[empty string]
OBJECTIDBE78B22A-5056-8300-08A1064B2590E633
OWNEDBY[empty string]
PARENTIDFC907F30-A9C0-11E3-A473005056830008
PREFERENCE1st
SEQ1
TICKETSTATUSOffered
TYPENAMEAflGameClient


Blair McKenzie

unread,
Mar 14, 2014, 1:35:36 AM3/14/14
to Unname
Looks right to me. Is it not working?

AJ Mercer

unread,
Mar 14, 2014, 1:40:15 AM3/14/14
to farcr...@googlegroups.com
Message: Element name is undefined in a CFML structure referenced as part of an expression.

  • \farcry\core\tags\formtools\object.cfm (line: 328)
  • \farcry\core\tags\formtools\object.cfm (line: 309)
  • \farcry\core\tags\formtools\object.cfm (line: 42)
  • \farcry\core\tags\formtools\object.cfm (line: 1)
  • \farcry\plugins\pslClient\packages\types\AflGame.cfc (line: 53)

Sean Coyne

unread,
Mar 14, 2014, 9:18:51 AM3/14/14
to farcr...@googlegroups.com
AJ, for what its worth, I was always a big fan of the extended array concept, however, every time I have used them I have regretted it.  I have always gone back and replaced it with an intermediary custom type.  So you create a new custom type that holds all the extended info & a pointer to the actual record you are linking to.  Not sure I explained that well, but hopefully you get what I mean.

Extended arrays are great in theory, but I find there are just too many bugs that crop up because they are just not used often enough and don't get the same attention as regular types/rules. The maintenance issues of having to write a customized edit UI for that portion also contributes to my past frustrations.

Just my two cents.


With regards to the error...

I think the problem is that the extended array struct reports the wrong typename.  So the "typename" is the type of the object being pointed to by the "data" property. Think of a regular array... there are 4 primary fields, data, parentid, seq, and typename.  Typename is the type of the object for the "data" field.

So extended arrays carry this over.

However, in your case the actual typename for the extend array object is myParentType_aWhateverProperty so rather than pass the struct as is as Blair suggests, you either have to use getData() on the extended array type using the objectid property of the struct to retrieve the "real" struct OR, pass the objectid AND a typename attribute to the ft:object tag.

See what I was saying about extended arrays being buggy/weird?? :)

AJ Mercer

unread,
Mar 14, 2014, 9:42:10 AM3/14/14
to farcr...@googlegroups.com
Hi Sean

Just a quick reply to say thanks for the reply and will get back to it on Monday 

I may be celebrating my team's win a little too hard to take this all on right now - if you know what mean ;-)
--
You receive
Reply all
Reply to author
Forward
0 new messages