How to build fully qualified URLs automatically ?

An excerpt from the ColdBox Docs:
- http://wiki.coldbox.org/wiki/URLMappings
- How about links on my pages?
  - The best one is:
  <a href="#event.buildLink('home.about')#">About</a>

When I place such a link/anchor on a .cfm page, the 'href' attribute
receives a fully qualified URL ! Now what I would like to have is:
Fully qualified URLs which I can build automatically standalone; to
use them in other contexts than just the 'href' attribute of links/
anchors. So the question is: Which ColdBox method can build those
fully qualified standalone URLs ?

what other contexts are you talking about, give an example.

For instance, using those URLs for Isomorphic's SmartClient
Components; this is actually the use case which made me post this
thread.

Not knowing this framework, how would you normally call these components?

From what I can tell this is an Ajax framework, which means that you define how the calls would be made, would that be right?

If that is the case then I see no reason why you couldn’t already use event.buildLink() the same way.

Do you have an example piece that you are more referring too?

SmartClient (Ajax) Components have attributes - NOT named 'href' -
which I assign values to at creation time; oftentimes, fully qualified
URLs are needed as attribute values; event.buildLink() alone isn't
enough ... Only if I use it for the 'href' attribute of links/anchors
a fully qualified URL seems to be automagically constructed by
ColdBox ...

I think you are missing the point.

event.buildLink() builds a url that can be used anywhere that you want.

When I asked for an example of what you are trying it with, it would be similar to this bit of javascript code that I have for extJs.

Ext.Ajax.request({
url: ‘#event.buildLink(’/handler/action/’)#’ + selected,
method: ‘post’,
scripts : true,
success: servicesLoaded,
failure: function ( result, request ) {
alert(“failure”);
}
});

You need to think about it this way, this will build a URL string that can be used anywhere that you need to use a url for, don’t think that it is only used for href.

Now do you understand why I asked for an example of why you are asking, because here is an example of me using it with extJs.

I now do it like so:
- <cfset loginURL = "#event.buildLink("general.about", true)#" />
- then assign the value of loginURL to a JavaScript variable
iscLoginURL
- then use the JavaScript variable iscLoginURL as the SmartClient
attribute value
- the value of iscLoginURL is: /index.cfm?event=General.About
- but in this case, it works for the SmartClient Component at hand:
Everything is relative :slight_smile:

Thank You very much for Your efforts !

Should the need for fully qualified URLs arise in other scenarios, I
will come back to this thread !

You can pass in a baseURL to the build link, and if you are using SES, you have a setting called htmlBaseURL that would work

#event.buildLink(linkto='home.about',baseURL="#getSetting('htmlBaseURL')#")#

Curt Gratz
Computer Know How