-
1. Re: Simple cfc mapping issue = I am a muppet
Adam Cameron. Jul 7, 2010 1:50 AM (in response to Owain North)Consider what values you'd put in to CFAdmin if you were making that mapping... and hopefully notice what you're missing from your statement in Application.cfc.
Hint: what's the first character of the logical path you'd specify for any mapping you make in CFAdmin?
Hint 2: it's in the docs: http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0b63c -7fd5.html#WS0C5B9A8B-32B5-4db2-BC04-B76DF8823A34 (it took me a bit to find this, so I wouldn't be concerned if you missed it when you looked).
--
Adam
-
2. Re: Simple cfc mapping issue = I am a muppet
Adam Cameron. Jul 7, 2010 1:51 AM (in response to Owain North)THIS.Mappings["horses"] = 'badgers' ;
More advice: be very careful when putting a saddle on that particular "horse".
--
Adam
-
3. Re: Simple cfc mapping issue = I am a muppet
Owain North Jul 7, 2010 2:56 AM (in response to Adam Cameron.)Ah, it seems I'd done two things wrong.
Firstly, I needed a forward slash at the start of the mapping, which I believe is what Adam was getting at.
Secondly when doing mappings it seems you can only do them to physical directories, not CFC paths. At first I thought this was odd (and it's caught me out before) as if I can do createObject("system.cfc.classes.MyClass") then why can't I have a mapping to "system.cfc.classes"?
I can only assume this is to keep mappings generic - they can be used for physical directories and component paths so I guess the physical path is required.
All sorted now with this:
THIS.Mappings["/horses"] = 'g:\websites\mywebsite\htdocs\badgers' ;
Not quite as clean as I would have liked but still, if it's what needs doing.
Cheers Adam
O.
-
4. Re: Simple cfc mapping issue = I am a muppet
Adam Cameron. Jul 7, 2010 3:17 AM (in response to Owain North)Trying to do a mapping to a dotted CFC path is a bit of a circular idea, because CF needs to know where in the file system the CFC dotted path points to to be able to resolve it to a CFC file.
Also, as you touch on, CF mappings are for more things than just CFC resolution.
However you can use expandPath() on the RHS of the mapping, so I do this sort of thing:
this.mappings["/myapp"] = expandPath("/com/mycompany/myapp/");
One does not need to hard-code the entire path.
--
Adam
-
5. Re: Simple cfc mapping issue = I am a muppet
Owain North Jul 7, 2010 3:35 AM (in response to Adam Cameron.)Ah yes, that's a little tidier - I've always been careful with getCurrentTemplatePath() as I know in certain circumstances (onRequestStart()?) it can cause unexpected behaviour if the calling page is in a subdirectory - however I do appreciate it works in this case.
UsingexpandPath() is certainly tidier, so I reckon I'll use that.
Cheers
O.

