Scaffoldnig and CF9 ORM?

19 views
Skip to first unread message

marc

unread,
Jan 5, 2012, 10:08:10 AM1/5/12
to model...@googlegroups.com
Hi,
I have a sample app that uses scaffolding to add, opdate and show data from a table "pages". I have configured scaffolding in Coldspring.xml and told MG I use Hibernate for an orm by adding the lines

<alias alias="ormAdapter" name="ormAdapter.cfORM" /> 
<alias alias="ormService" name="ormService.cfORM" />         

No other ORM frameworks (Transfer,Reactor) are configured here
Also I have configured the CF app for orm by setting this.ormenabled="true"and adding the necessary ormsetting parameters in Application.cfc. I also have a page.cfc that is set to persistent so all actions to manage data to should be managed here. It has an init and a List handler that returns EntityLoad("page").

MG displays an listpage and, when clicking the "add page" link there, an edit page. That form shows all the properties defined in my ORM's page.cfc so it seems MG can talk to Hibernate.

The "pages" table is empty so I want to add data by filling in the edit form. When I fill and submit that form, nothing is added to the pages table so I think I miss something here...

Do I have to add list,view,edit,commit,delete functions to the page controller and have those in turn call the corresponding functions in the ORM (page.cfc)?
Do I have to add create list,view,edit,commit,delete functions to the page.cfc entity?
What datastructures is the generated view expecting when displaying data? A query resultset? An array of beans?

Sorry for asking basic questions but I am new to Scaffolding and this is my first try with Hibernate. Also, I don't find this mentioned in the docs @ http://docs.model-glue.com/wiki/HowTos/HowToUseScaffolds#Scaffolds
Thanks,

Marc

Dan Wilson

unread,
Jan 5, 2012, 10:20:59 AM1/5/12
to model...@googlegroups.com
Marc,

Sorry you are having trouble with this. We've not done a very good job of documenting the new CF9 Hibernate interactions in Model Glue and this is one of the main reasons we've not fully released the code yet. We could use a hand with this if you are so inclined.

I'm a little sketchy myself about the particulars of the CF9 Plugin, but scaffolding always generates the XML definitions in a file called scaffolds.xml (or something similar). This should be in your config directory. By default, these options should be enabled:

  • Display a "master list" of records in a table
  • Display an editing form capable of editing both a record's data and its relations to other tables (one-to-many and many-to-many)
  • Display a read-only view of a record
  • Update a record's data
  • Delete a record 
There are ways to limit this, by changing the scaffold tag, but the default is to generate the above.

If your data is not saving, it is possibly because the Hibernate mappings are not correct. Sometimes this happens when the primary key is not set. 

All of the generated CFM view files are located in the /model/generated directory (unless this was renamed in the ModelGlueConfiguration. I believe all of the list methods are looking for a query. The display and edit methods are looking for beans. You may wish to verify this with your generated code. We made a lot of effort in making the generated code easy to read.

I'm sure others will weigh in on this, but post back what you find. And should you be in a place to help us out with some details we can add to the documentation to help folks like yourself, I'd be very much appreciative.


DW




--
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 model...@googlegroups.com
To unsubscribe from this group, send email to
model-glue+...@googlegroups.com
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."

marc

unread,
Jan 5, 2012, 10:46:41 AM1/5/12
to model...@googlegroups.com
Ok, fair enough. It's a free framework after all.

I studied the docs on scaffolding (http://docs.model-glue.com/wiki/HowTos/HowToUseScaffolds/CustomizingGeneratedCfml#Scaffolds:CustomizingGeneratedCFML). There it says:

"Scaffold tags cause certain files to be generated, such as lists, views, and edit forms. This generated code is placed into a directory governed by the ScaffoldPath property of the ModelGlueConfigurationBean in ColdSpring.xml."

I think what you mean here is generatedViewMapping instead of ScaffoldPath. generatedViewMapping lets you determine where generated views should to be saved to. ScaffoldPath lets you define the location of Scaffolds.xml.

Is it possible to add stuff like this to the MG docs the way the CF docs let you?

Btw I find the MG documentation quite clear and to the point. Also I'm happy to contribute and fill in the parts I feel are missing as soon as I get my head around it.

Marc

Dan Wilson

unread,
Jan 5, 2012, 10:52:13 AM1/5/12
to model...@googlegroups.com
Cool, Thanks.

The docs site is publically editable. So make whatever changes you want. We'll be notified and can do any clean up...

Sometimes it's easier if folks give us a rough draft of what is needed, versus us trying to think up what a new comer to the feature would need.... Then again, sometimes we are just bogged down with other thing...

If you are able to make some edits/improvements, you'll get a lifetime supply of Model-Glue.

DW




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 model...@googlegroups.com
To unsubscribe from this group, send email to
model-glue+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Ezra Parker

unread,
Jan 5, 2012, 3:03:37 PM1/5/12
to model...@googlegroups.com
At present the scaffolding documentation is rather out-of-date, I'm
afraid, as it was written for Model-Glue 2, and scaffolding was
revamped in version 3. Some of it is certainly still relevant, but
other portions are not (most notably the "Customizing" pages). I am in
the midst of putting this together, but it's not up on the site quite
yet.

I also wanted to note that a little while ago we disabled anonymous
editing of the MG wiki, as we were being inundated with spam, and were
not having much luck with Trac's spam filter. Marc, please email me
off-list to let me know what you would like your username to be, and
I'll set up an account for you.

Oh, and you're quite right regarding the generatedViewMapping setting,
I went ahead and made that change (thanks very much for pointing it
out).

As to the specific questions you posed:

> Do I have to add list,view,edit,commit,delete functions to the page controller and have those in turn call the corresponding functions in the ORM (page.cfc)?

No. You don't actually need a controller at all if you're only using
scaffolding, as the data retrieval/persistence is all handled by GDMs
(Generic Database Messages):

http://docs.model-glue.com/wiki/HowTos/HowToUseGenericDatabaseMessages

You can take a look at the generated Scaffolds.xml file to see how
it's putting the event-handlers together.

> Do I have to add create list,view,edit,commit,delete functions to the page.cfc entity?

No, the CF 9 ORM adapter and service take care of this functionality.

> What datastructures is the generated view expecting when displaying data? A query resultset? An array of beans?

Dan is exactly correct that the list views are passed a query, and the
display and form views are passed an entity bean.

HTH,

--
Ezra Parker

Reply all
Reply to author
Forward
0 new messages