Yes! This works.

I created a copy of the
/ModelGlue/gesture/modules/orm/cform/cfORMService.cfc, added
extends="ModelGlue.gesture.modules.orm.cform.cfORMService", removed all
methods except List() which I adapted (returnType="array". Then I added
this in my projects ColdSpring.xml:

<bean id="ormService.cfORM" class="services.cfORMService" />

(note the id: "ormService.cfORM", it's not "ormService").

Now MG is using the modified cfORMService instead of it's own.

Thanks all!

Marc

On Thu, Jan 26, 2012 at 6:31 PM, Chris Blackwell <[email protected]> wrote:

> ModelGlue.GenericList doesn't pass your returnType argument through to the
> ormService, so its always going to return a query.
>
> I think, if you want ormService to return an array of entities (without
> altering MG internals) you'll need to override the ormService bean as I
> described
>
> Chris
>
>
> On 26 January 2012 17:03, Marc Bakker <[email protected]> wrote:
>
>> Hi Dan,
>>
>> looks super clear but I keep; getting a query instead of a ;list of
>> entities...
>> here's what I did
>>
>> copy /ModelGlue/gesture/modules/scaffold/beans/plain/List.cfc
>> to
>> /CFlab/Application/model/scaffoldTemplates/List.cfc
>>
>> add a mapping /scaffoldTemplates in /Application.cfc that points to
>> F:/www/CFlab/Application/model/scaffoldTemplates/
>>
>> change
>> List.cfc:
>>
>>     <cfset xml = xml & '>
>>             <broadcasts>
>>                 <message name="ModelGlue.genericList">
>>                     <argument name="criteria" value="" />
>>                     <argument name="object" value="#arguments.alias#" />
>>                     <argument name="queryName"
>> value="#arguments.alias#Query" />
>>                 </message>
>>             </broadcasts>
>>
>> by adding
>>
>>                     <argument name="returnType" value="array" />
>>
>>
>> to the <broadcasts> section
>>
>> so I should get no query resultset from the List method
>>
>> in coldspring.xml add this to point to the new modifield List.cfc:
>>
>> <bean id="modelglue.scaffoldType.List"
>> class="coldspring.beans.factory.config.MapFactoryBean">
>>     <property name="SourceMap">
>>         <map>
>>             <entry
>> key="class"><value>scaffoldTemplates.List</value></entry>
>>
>>             <event key="hasXMLGeneration"><value>true</value></event>
>>             <event key="hasViewGeneration"><value>true</value></event>
>>             <entry key="prefix"><value>List.</value></entry>
>>
>>             <entry key="suffix"><value>.cfm</value></entry>
>>         </map>
>>     </property>
>> </bean>
>>
>> all I changed it this line <entry
>> key="class"><value>CFLab.Application.model.scaffoldTemplates.List</value></entry>
>> to point to the modifield List.cfc.
>>
>> It looks like MG is not picking up on the new List.cfc. Whatever I put in
>> it (e.g. <cfabort>),has no consequences.
>> Is the use of the mapping "/scaffoldTemplates" correct?
>>
>> Btw, in Coldspring.xml  rescaffold=true, reload=true
>>
>> Marc
>>
>>
>>
>> On Thu, Jan 26, 2012 at 5:08 PM, Dan Wilson <[email protected]> wrote:
>>
>>> I documented this on the training class wiki section:
>>>
>>> http://docs.model-glue.com/wiki/Training/Section08
>>>
>>>
>>> It's under Bonus Points. Hopefully the process will be clearer than my
>>> previous email.
>>>
>>>
>>> DW
>>>
>>>
>>>
>>> On Thu, Jan 26, 2012 at 10:46 AM, Dan Wilson <[email protected]> wrote:
>>>
>>>> Yup... though it bears mentioning it is very easy to change the
>>>> patterns ModelGlue uses for scaffolding. So there is no need to update tons
>>>> of files.
>>>>
>>>>
>>>> In this article:  http://docs.model-glue.com/wiki/Training/Section08
>>>>
>>>> You can see how to alter the provided scaffolds. You can also make your
>>>> own scaffold pattern and call it something else. After you register it with
>>>> Model Glue, you can call it like this:
>>>>
>>>> *MG Code:*
>>>> <scaffold object="Post" type="Delete,Grid,Edit"/>
>>>>
>>>> *ColdSpring Code:*
>>>>
>>>> <bean id="ScaffoldTemplate.Grid"
>>>>  factory-bean="modelglue.scaffoldManager"
>>>> factory-method="addScaffoldTemplate" lazy-init="false">
>>>>  <constructor-arg name="scaffoldBeanRegistry">
>>>> <list>
>>>>  <ref bean="mgtest.scaffoldTemplate.Grid" />
>>>> </list>
>>>>  </constructor-arg>
>>>> </bean>
>>>> <bean id="mgtest.scaffoldTemplate.Grid"
>>>> class="coldspring.beans.factory.config.MapFactoryBean">
>>>>  <property name="SourceMap">
>>>> <map>
>>>> <entry key="class"><value>mgtest.model.Grid</value></entry>
>>>>  <event key="hasXMLGeneration"><value>true</value></event>
>>>> <event key="hasViewGeneration"><value>true</value></event>
>>>>  <entry key="prefix"><value>Grid.</value></entry>
>>>> <entry key="suffix"><value>.cfm</value></entry>
>>>>  </map>
>>>> </property>
>>>> </bean>
>>>>
>>>>
>>>>
>>>> Note, the class parameter will point to your CFC in your project (or
>>>> elsewhere) you made for your generational pattern. I recommend starting
>>>> (not altering) the ones that ship with Model Glue and placing your altered
>>>> CFC inside your project.
>>>>
>>>>
>>>> DW
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Thu, Jan 26, 2012 at 10:39 AM, Chris Blackwell <[email protected]>wrote:
>>>>
>>>>> You could create a component that extends *
>>>>> ModelGlue.gesture.modules.orm.cform.cfORMService* overriding the
>>>>> list() method to return an array of entities by default.
>>>>>
>>>>> Then tell ModelGlue to use your service rather than its own in your
>>>>> ColdSpring.xml
>>>>>
>>>>> <bean id="ormService" class="model.service.myCfOrmService" />
>>>>>
>>>>> But, as Dan mentioned, this will break the default views that are
>>>>> generated.
>>>>>
>>>>> Chris
>>>>>
>>>>>
>>>>> On 26 January 2012 15:24, Matt Quackenbush <[email protected]>wrote:
>>>>>
>>>>>> Not sure where the code calls on list(), but if you provide
>>>>>> `returnType="ANYTHING_BUT_QUERY"` then you will be delivered the array of
>>>>>> entities.
>>>>>>
>>>>>> So, check farther up the execution chain and see where you can pass,
>>>>>> say, `returnType="array"`, and you should be all set.
>>>>>>
>>>>>>
>>>>>> On Thu, Jan 26, 2012 at 9:21 AM, marc <[email protected]> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am playing with ModelGlue scaffolding feature with CF9 Hibernate
>>>>>>> ORM. I find that the List event handler returns a query result set of 
>>>>>>> all
>>>>>>> my records in table, whereas cf9 EntityLoad() returns an array of
>>>>>>> entiities. When I look in the MG framework where it executes List() , I 
>>>>>>> see
>>>>>>> that the handler initially retrieves an array of entities via 
>>>>>>> EntityLoad().
>>>>>>> Then MG converts the returned array with objects to a query with
>>>>>>> EntitytoQuery().
>>>>>>>
>>>>>>> I'd rather have an array of objects than a simple query resultset.
>>>>>>> Can I change MG so that this behaviour is configurable?
>>>>>>>
>>>>>>> Here is the MG code where a list of objects is retrieved and then
>>>>>>> convreted to a struct:
>>>>>>>
>>>>>>> in /ModelGlue/gesture/modules/orm/cform/cfORMService.cfc
>>>>>>>
>>>>>>>     any function list(required string entityName, struct
>>>>>>> filterCriteria=StructNew(), string sortOrder="", string 
>>>>>>> returnType="query")
>>>>>>> {
>>>>>>>         var list =
>>>>>>> EntityLoad(arguments.entityName,arguments.filterCriteria,arguments.sortOrder);
>>>>>>>         if (arguments.returnType eq "query") {
>>>>>>>             list = EntitytoQuery(list);
>>>>>>>         }
>>>>>>>         return list;
>>>>>>>     }
>>>>>>>
>>>>>>> As far as I can see the argument returnType is not specified in the
>>>>>>> calling component 
>>>>>>> (/ModelGlue/gesture/modules/orm/cform/cfORMAdapter.cfc)
>>>>>>> so it always defaults to "query".
>>>>>>>
>>>>>>> Marc
>>>>>>>
>>>>>>> --
>>>>>>> Model-Glue Sites:
>>>>>>> Home Page: http://www.model-glue.com
>>>>>>> Documentation: http://docs.model-glue.com
>>>>>>> Bug Tracker: http://bugs.model-glue.com
>>>>>>> Blog: http://www.model-glue.com/blog
>>>>>>>
>>>>>>> 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
>>>>>>
>>>>>>
>>>>>>  --
>>>>>> Model-Glue Sites:
>>>>>> Home Page: http://www.model-glue.com
>>>>>> Documentation: http://docs.model-glue.com
>>>>>> Bug Tracker: http://bugs.model-glue.com
>>>>>> Blog: http://www.model-glue.com/blog
>>>>>>
>>>>>> 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
>>>>>>
>>>>>
>>>>>  --
>>>>> Model-Glue Sites:
>>>>> Home Page: http://www.model-glue.com
>>>>> Documentation: http://docs.model-glue.com
>>>>> Bug Tracker: http://bugs.model-glue.com
>>>>> Blog: http://www.model-glue.com/blog
>>>>>
>>>>> 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
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Plutarch - "The mind is not a vessel to be filled but a fire to be
>>>> kindled."
>>>>
>>>
>>>
>>>
>>> --
>>> Plutarch - "The mind is not a vessel to be filled but a fire to be
>>> kindled."
>>>
>>> --
>>> Model-Glue Sites:
>>> Home Page: http://www.model-glue.com
>>> Documentation: http://docs.model-glue.com
>>> Bug Tracker: http://bugs.model-glue.com
>>> Blog: http://www.model-glue.com/blog
>>>
>>> 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
>>>
>>
>>
>>
>> --
>>
>> Met vriendelijke groet,
>>
>> Marc Bakker
>>
>>
>>  --
>> Model-Glue Sites:
>> Home Page: http://www.model-glue.com
>> Documentation: http://docs.model-glue.com
>> Bug Tracker: http://bugs.model-glue.com
>> Blog: http://www.model-glue.com/blog
>>
>> 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
>>
>
>  --
> Model-Glue Sites:
> Home Page: http://www.model-glue.com
> Documentation: http://docs.model-glue.com
> Bug Tracker: http://bugs.model-glue.com
> Blog: http://www.model-glue.com/blog
>
> 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
>



-- 

Met vriendelijke groet,

Marc Bakker

-- 
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog

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

Reply via email to