Ticket #226 (closed defect: worksforme)
Alias Problems Consolidated
| Reported by: | Bryan S | Owned by: | somebody |
|---|---|---|---|
| Priority: | highest | Milestone: | 2.0 Beta 2 |
| Version: | Severity: | blocker | |
| Keywords: | Cc: |
Description
I am running into one problem after another working with scaffolding, a table structure with one to many relationships and aliased columns. Everything works great if I use the original database object name but if I use the aliased column names I fix one bug only to be stopped by another. Since I don't have a full grasp of the design of Model Glue I'm getting to the point where I believe my fixes are hacks and describing them all will be counter productive. I think it will be easier for whomever to reproduce them. A picture is worth a thousand words kind of thing.
I have attached files that will allow you to easily create my simple schema and the reactor.xml and ModelGlue?.xml that works for the object names but not the alias names.
I made it through a number of issues in reactor (which it appears were due to my inexperience) and now I've come out in Model Glue and I ran into a problem where the object name was being used to call getPRE_COLUMN_NAME() instead of using the alias name to call getColumnName(). I fixed that by doing what is below but now I ran into a problem where setPRE_COLUMN_NAME is being called instead of setColumnName at line 377 of D:\Inetpub\wwwroot\ModelGlue?\unity\orm\ReactorAdapter?.cfc
If there is something you need to know to help me please ask. Thanks.
The first problem was fixed by changing this in D:\Inetpub\wwwroot\ModelGlue?\unity\controller\ReactorORMController.cfc line 195
was
<cfloop from="1" to="#arrayLen(metadata.primaryKeys)#" index="i">
<cfinvoke component="#record#" method="get#metadata.primaryKeys[i]#" returnvariable="tmp" /> <cfset arguments.event.setValue(metadata.primaryKeys[i], tmp) />
</cfloop>
is now
<cfloop collection="#metadata.properties#" item="j" >
<cfif metadata.primaryKeys[i] EQ metadata.properties[j].name>
<cfinvoke component="#record#" method="get#metadata.properties[j].alias#" returnvariable="tmp" />
</cfif>
</cfloop> <cfset arguments.event.setValue(metadata.primaryKeys[i], tmp) />
</cfloop>
I also ran into these problems in the xsl files
edit.xsl
had to change select="name"/> to select="alias"/>
<xsl:if test="relationship = 'false'">
<div class="formfield">
<label for="<xsl:value-of select="name"/>" <cfif structKeyExists(validation, "<xsl:value-of select="alias"/>")>class="error"</cfif>><b><xsl:value-of select="label"/>:</b></label>
had to comment out because it wasn't a valid query
<cfif viewstate.exists("<xsl:value-of select="alias"/>|<xsl:value-of select="sourcekey"/>")>
<cfset selectedList = viewstate.getValue("<xsl:value-of select="alias"/>|<xsl:value-of select="sourcekey"/>") />
<cfelse>
<cfset selectedList = valueList(selectedQuery.<xsl:value-of select="sourcekey"/>) />
</cfif>
had to comment out because the query didn't exist because of above
<input type="hidden" name="<xsl:value-of select="alias"/>|<xsl:value-of select="sourcekey"/>" value="" />
<div class="formfieldinputstack">
<cfoutput query="valueQuery">
<label for="<xsl:value-of select="alias"/>_#valueQuery.<xsl:value-of select="sourcekey"/>#"><input type="checkbox" name="<xsl:value-of select="alias"/>|<xsl:value-of select="sourcekey"/>" id="<xsl:value-of select="alias"/>_#valueQuery.<xsl:value-of select="sourcekey"/>#" value="#valueQuery.<xsl:value-of select="sourcekey"/>#"<cfif listFindNoCase(selectedList, "#valueQuery.<xsl:value-of select="sourcekey"/>#")> checked</cfif>/>#valueQuery.<xsl:value-of select="sourcecolumn"/>#</label><br />
</cfoutput>
</div>
![(please configure the [header_logo] section in trac.ini)](/ModelGlue.com/trac.cgi/chrome/site/your_project_logo.png)