Wednesday, March 21, 2007

accessing Coldfusion Components (CFC's) question

I haven't had any problems accessing my components (CFC's) when I use dot notation on my localhost, nor have I ever had problems using dot notation when I have a path mapping set up on a remote server. However, this (below) does not work when calling out components in an environment where a mapping is disallowed (shared environment, for instance, where you don't have access to CF adminstrator)-- I'm trying to get my process created in a way that doesn't require me to use full paths, for ANT builds, etc that can be ported to different machines).

Any suggestions for how to access components in a directory such as, for example, wwwroot/ApplicationName/Model/Components

where I cannot have a mapping setup? Is there a way to do this with CFOBJECT (in a modified format from below), or do I need to resort to CFINVOKE? If so, what would the path callout look like using CFOBJECT or CFINVOKE?:

<cfobject name="oContactData" component="ApplicationName.Model.Components.CFCmyprofile ">
<cfset qContacts = #oContactData.getMyContacts(SESSION.auth.SkillshowUserID, -1)#>


Looking for a modified line of the above code that works in a relative path manner-

3 comments:

Unknown said...

Mark,

This doesn't exactly handle "relative" paths, per-say, however, it can easily be set up to let Application handle the CFC creation. Take a look at this:

http://bennadel.com/index.cfm?dax=blog:348.view

It details exactly the issue you are trying to overcome. I hate mapped paths... down with paths!

Unknown said...

That absolutely should work - unless your hosting provider is stupid enough to have created a mapping for "/" which breaks CFC lookup.

Who is your shared hosting provider?

Mark Holton said...

Hi Ben, Sean,
Thanks for the info, and the confirmation. I'm going to give that a spin tonight. I might have some questions later!

...it's too bad this isn't built into CFC's in a more robust manner. It would seem that MVC, and the ability to access CFC's via relative paths would be a main requirement (for ANT builds, etc). If I'm missing something, someone please alert me. Ben's path looks like a good one to go down.

Thanks and cheers-