the singularity of being and nothingness
Archive for April, 2012
ColdFusion Bug: SerializeJSON() and ORM Entities
Apr 26th
Recently, I’ve been messing around quite a bit with ORM in ColdFusion. I really like the benefits that it brings to developing applications. However, I noticed a very big bug yesterday while attempting to user serializeJSON() on a an entity using a one-to-many relationship.
Some ContextLet’s say that you have two entities that are related via a one-to-many relationship (Artists and Art, for example). You can easily create this relationship in your model by doing something like the following:
property name="art" fieldtype="one-to-many" fkcolumn="artistid" cfc="Art" remotingfetch="true";
If we were to dump the result of an EntityLoad() of “Artists”, we’d see a nice structured relationship: First, an array of all Artist entities, and then an array of all Art entities related to the particular ArtistID. Additionally, I’ve specified remotingfetch=true, which will force CF to load the Art entities for each Artist.
The BugThe bug, however, comes into play when you try to serialize the result of EntityLoad(). While it properly composes the relationships, it represents the first two entities in the “art” array; any subsequent entities in the given array are returned simply as “{}”. Whether you have 3 “Art” entities for an artists, or 20, only the first 2 will ever be serialized properly.
See More >
ExtJS 4: Applying Model Validations to Forms
Apr 23rd
One of my absolute favorite things about ExtJS’ data model is how simple it is to apply a Model instance to a form. If you’ve never done this before, consider the following data model:
Ext.define('Validations.model.Person', { extend: 'Ext.data.Model', fields: [ {name:"name", type:'string'}, {name:"age", type:"int"}, {name:"hobby", type:"string"} ] })
Also, assume we have a form defined like so:
Ext.define('Validations.view.people.Form', { extend: 'Ext.form.Panel', alias: 'widget.peopleform', bodyPadding: 10, border: false, initComponent: function() { var me = this; Ext.applyIf(me, { defaults: { width: 250, labelWidth: 70 }, items: [ { xtype: 'textfield', name: 'name', fieldLabel: 'Name' }, { xtype: 'numberfield', name: 'age', fieldLabel: 'Age', value: 20 }, { xtype: 'textfield', name: 'hobby', fieldLabel: 'Hobby' } ] }); me.callParent(arguments); } })
NOTE: Notice that the “name” properties of each form field maps 1:1 with the “name” properties in my Model.
Now, let’s say that we want to edit a Model instance. We could, of course, manually set the value of each form field to that of the corresponding field in the Model. However, this is clunky and unnecessary, given that the form itself has a method for doing this automatically. Consider the following:
// get More >
Quick Thoughts on Sencha Architect 2
Apr 21st
A few days ago, Sencha rolled out Sencha Architect 2, the major overhaul and rebranding of what was formerly Sencha Designer. You can check out the release blog post to get the low-down on all the new features.
When I saw the news about the release, I have to say I was a bit hesitant to look much further. I’ve tried Sencha Designer several times in the past, and I’ve been somewhat disappointed with it. Sure, it was great for laying out apps, but when you actually needed to *code*, it was lackluster at best. But even worse, I found it to be very buggy; it would crash at random times, and overall I found the process of trying to mockup an app to be more frustrating than anything else.
So initially, I wasn’t planning on even trying out the newest iteration. But then I noticed that one of the biggest additions to the product is support for creating a full ExtJS or Touch app–not just the UI. I felt I had to take a closer look, and I’m glad I did.
UIOut of the box, Architect 2 is worlds better than its previous iterations. The interface is slick and responsive, and the way More >