How to build fully qualified URLs automatically ?

58 views
Skip to first unread message

verlsnake

unread,
Oct 4, 2011, 11:38:45 AM10/4/11
to ColdBox Platform
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 ?

Andrew Scott

unread,
Oct 4, 2011, 11:54:50 AM10/4/11
to col...@googlegroups.com
what other contexts are you talking about, give an example.


--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org



--
Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/


verlsnake

unread,
Oct 4, 2011, 2:40:19 PM10/4/11
to ColdBox Platform
For instance, using those URLs for Isomorphic's SmartClient
Components; this is actually the use case which made me post this
thread.


On Oct 4, 5:54 pm, Andrew Scott <andr...@andyscott.id.au> wrote:
> what other contexts are you talking about, give an example.
>
>
>
> On Wed, Oct 5, 2011 at 2:38 AM, verlsnake <k...@kaitischler.de> wrote:
> > 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 ?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "ColdBox Platform" group.
> > To post to this group, send email to col...@googlegroups.com
> > To unsubscribe from this group, send email to
> > coldbox-u...@googlegroups.com
> > For more options, visit this group at
> >http://groups-beta.google.com/group/coldbox
> > For News, visithttp://blog.coldbox.org
> > For Documentation, visithttp://wiki.coldbox.org

Andrew Scott

unread,
Oct 4, 2011, 2:53:26 PM10/4/11
to col...@googlegroups.com
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?



For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org

verlsnake

unread,
Oct 4, 2011, 3:48:12 PM10/4/11
to ColdBox Platform
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 ...

Andrew Scott

unread,
Oct 4, 2011, 3:56:28 PM10/4/11
to col...@googlegroups.com
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.



-- 
Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/

verlsnake

unread,
Oct 4, 2011, 4:35:27 PM10/4/11
to ColdBox Platform
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 :-)

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 !

Curt Gratz

unread,
Oct 5, 2011, 7:24:07 AM10/5/11
to col...@googlegroups.com
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

Reply all
Reply to author
Forward
0 new messages