sub-classing is obviously a better idea than change the core code, in my
haste to figure out how it could be done i really didn't think through the
implementation :)


2008/9/23 Doug Hughes <[EMAIL PROTECTED]>

> You know, that's actually a fairly good idea as well!  You could simply
> apply advice to the adaptor that added metadata to the XML conditionally.
>
> Doug Hughes, President
> Alagad Inc.
> [EMAIL PROTECTED]
> 888 Alagad4 (x300)
> Office: 919-550-0755
> Fax: 888-248-7836
>
>
> On Tue, Sep 23, 2008 at 3:52 PM, Gareth Cole <[EMAIL PROTECTED]> wrote:
>
>>  Thanks for the help folks. I'm going to give this a go later this week.
>>
>>
>>
>> The ormAdapter is already defined in my MGU coldspring file, so I reckon
>> I could just create a CFC that sub-classes ReactorAdapter.cfc and
>> over-rides that method. I feel more comfortable with that than editing the
>> core files.
>>
>> Would the AOP side of ColdSpring be a solution here?
>>
>>
>>
>> -----Original Message-----
>> *From:* [email protected] [mailto:[EMAIL PROTECTED]
>> *On Behalf Of *Doug Hughes
>> *Sent:* 23 September 2008 20:36
>> *To:* [email protected]
>> *Subject:* [Model-Glue] Re: custom scaffolding question
>>
>>
>>
>> I was thinking about this question.  (I'm considering doing the
>> scaffolding implementation in MG:G so I might as well.)
>>
>> I agree with Chris that you could edit the Reactor metadata and that might
>> work nicely for your project.  However, a more generic solution might be to
>> edit scaffoding system in Model-Glue itself.  Note that because the
>> framework is configured by ColdSpring you can override the core objects by
>> simply defining your own objects with the same ID in coldspring, extending
>> the core object and providing your own implementation.
>>
>> So, for a more generic system that is trasnfer and reactor agnostic you
>> might be able to create your own scaffolding adaptor that, behind the scenes
>> uses the tansfer or reactor adaptor and combines metadata from the ORM with
>> configuration that you provide.  IE: define your own additional metadata in
>> XML and merge the two documents into one and pass that into the xsl
>> translation.
>>
>> Now, having written that, I haven't actually dug into code to see if that
>> would even work, but it's an idea!
>>
>> Doug Hughes, President
>> Alagad Inc.
>> [EMAIL PROTECTED]
>> 888 Alagad4 (x300)
>> Office: 919-550-0755
>> Fax: 888-248-7836
>>
>>  On Tue, Sep 23, 2008 at 3:18 PM, Chris Blackwell <[EMAIL PROTECTED]>
>> wrote:
>>
>> Hi Gareth,
>>
>> The Reactor part to this is easy, open up your /model/data/Metadata folder
>> and add extra metadata to the table column to describe what type of form
>> field to use. The columns are stored in an array, refer to
>> reactor/project/your_project/Metadata/yourTableMetaData.cfc for the correct
>> position (it should be the ordinal position in the table).
>>
>> heres an example, i want date columns rendered with a "calendar" field
>> type
>>
>> /model/data/Metadata/NewsMetaData.cfc
>> <cfcomponent hint="I am the database agnostic custom Metadata object for
>> the News object.  I am generated, but not overwritten if I exist.  You are
>> safe to edit me."
>>     extends="reactor.project.mg2test.Metadata.NewsMetadata">
>>     <!--- Place custom code here, it will not be overwritten --->
>>
>>    <!--- fields[4] is the `Date` column --->
>>     <cfset variables.metadata.fields[4]["fieldtype"] = "Calendar" />
>>
>> </cfcomponent>
>>
>> Reactor will now return this extra property whenever metadata for the News
>> table is required.
>>
>> Getting Model-Glue to use this is a little trickier, and requires a little
>> hacking of the framework files.  In ModelGue/unity/orm/ReactorAdapter.cfc
>> you'll need to pull your new property and insert it into the MG's metadata
>> format.
>>
>> *After this block (about line 117)*
>>
>>     <!--- Add simple fields --->
>>     <cfloop from="1" to="#arrayLen(fields)#" index="i">
>>         <cfset md[fields[i].alias] = duplicate(fields[i]) />
>>         <cfset md[fields[i].alias].sourceObject = "" />
>>         <cfset md[fields[i].alias].sourceColumn = "" />
>>         <cfset md[fields[i].alias].sourceKey = "" />
>>         <cfset md[fields[i].alias].relationship = false />
>>         <cfset md[fields[i].alias].linkingRelationship = false />
>>         <cfset md[fields[i].alias].pluralRelationship = false />
>>
>> *Add*
>>         <cfif not StructKeyExists(md[fields[i].alias], "fieldtype")>
>>             <cfset md[fields[i].alias].fieldtype = "" />
>>         </cfif>
>>
>> Then at line 261, where the properties are looped over, add your new field
>> to the list
>>
>>                     <cfloop 
>> list="*fieldtype*,nullable,cfdatatype,primarykey,sourcecolumn,pluralrelationship,relationship,sourceobject,name,default,sourcekey,length,alias,label,comment"
>> index="j">
>>
>> You'll now be able to access the fieldtype property in your xsl files
>>
>> <xsl:if test="fieldtype = 'Calendar'">
>>   &lt;cfcalendar ... /&gt;
>> </xsl:if>
>>
>> I've never used this, but in my brief testing it seems to work fine.  I
>> can't think of a way to do this without altering ReactorAdpater.cfc, if i've
>> missed something obvious i'm sure others will chime in.
>>
>> Cheers, Chris
>>
>> 2008/9/23 Gareth Cole <[EMAIL PROTECTED]>
>>
>>
>>
>> Hi,
>>
>>
>>
>> I'm not sure if this question is better suited to the reactor mailing
>> list, but here goes:
>>
>>
>>
>> I'm using Model glue 2 with reactor and I've been playing about with
>> customising the scaffolding xsl files. I've found this really powerful, and
>> a lot easier than I thought. With a few changes to the xsl, I've really
>> reduced the time I spend customising generated forms.
>>
>>
>>
>> The xsl generates different types of form input depending on the DB field
>> type. What I'd like to do, is add an extra setting (probably in the reactor
>> config or metadata files), so that I can over-write the field type
>> generated, and introduce my own custom inputs.
>>
>>
>>
>> As an example, if database column 'comments' is a long text field, then by
>> default the xsl renders this as a <textarea>. If I want this to be a wysiwyg
>> editor, I need to edit it manually in the form. Ideally, I would like to
>> specify that the 'comments' column should render as a wysiwyg in a config
>> file somewhere, and then change the xsl to render it as a wysiwyg
>> automatically.
>>
>>
>>
>> Does anyone know if this is possible, and how I would go about it?
>>
>>
>>
>> Thanks,
>>
>>
>>
>> Gareth
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

For more about Model-Glue, check http://www.model-glue.com .
-~----------~----~----~----~------~----~------~--~---

Reply via email to