views:

67

answers:

3

Hi I am wondering if there is a way to regenerate the URL when any page is loaded in coldbox/CF9 when using event.buildLink ?

Currently I get http://cawksd05.codandev.local:8080/entries/editor when using event.buildlink.

But the correct url should have /index.cfm added to it as shown below:

/index.cfm/entries/editor

Is there a way to set this once and where does this get set as I am confused where to set this for all my pages so that /index.cfm gets added the the url prefix when I do an event.Buildlink.

Thanks Faheem

// General Properties setUniqueURLS(false); setAutoReload(false);

// Base URL if( len(getSetting('AppMapping') ) lte 1){ setBaseURL("http://#cgi.HTTP_HOST#/index.cfm"); } else{ setBaseURL("http://#cgi.HTTP_HOST#/#getSetting('AppMapping')#/index.cfm"); }

// Your Application Routes formatConstraints = {format="(xml|json)"};

addRoute(pattern="/api/:format/tasks/completed",handler="tasksAPI",action="list",constraints=formatConstraints,completed=true); addRoute(pattern="/api/:format/tasks",handler="tasksAPI",action="list",constraints=formatConstraints); addRoute(pattern="/api/:format?",handler="tasksAPI",action="invalid");

addRoute(pattern="/tasks/list/:status?",handler="tasks",action="index"); addRoute(pattern=":handler/:action?");

A: 

Sounds like you need to set the baseURL in the /config/Routes.cfm file

// Base URL
if( len(getSetting('AppMapping') ) lte 1){
    setBaseURL("http://#cgi.HTTP_HOST#/index.cfm");
}
else{
    setBaseURL("http://#cgi.HTTP_HOST#/#getSetting('AppMapping')#/index.cfm");
}

vs.

// Base URL
if( len(getSetting('AppMapping') ) lte 1){
    setBaseURL("http://#cgi.HTTP_HOST#/");
}
else{
    setBaseURL("http://#cgi.HTTP_HOST#/#getSetting('AppMapping')#/");
}
Aaron Greenlee
hi Aaron thanks for that this is what I have set in my routes.cfm however when i use a setNextEvent or buildlink in another handler it does not add the base url including the index.cfm.I will attach code for you to see.
Hi Aaron my code for that is added on the top of the page for routes.cfm.
also please note that if I add fwreinit=1 to my url that I am posting then the link works properly but without this the base url is not correct ie its without the index.cfm.
try setNextRoute() instead of setNextEvent.
Aaron Greenlee
A: 

Thanks will try that and how do I get around the problem of event.buildLink should i use setNextroute instead of that too?

faheem
Thanks will try that and how do I get around the problem of event.buildLink should i use setNextroute instead of that too?
faheem
Hi Luis thanks for the reply I have renit the application using fwrenit=1 and this has not had any effect and when using setnextevent the url does not have index.cfm in it when it should have.for example:http://cawksd05.codandev.local:8080/entries/editorit should be like this:http://cawksd05.codandev.local:8080/index.cfm/entries/editor but when i use setnextevent it eliminates the index.cfm. However this is all set properly inside my routes.cfm. so i am really not sure why this is not working ?
faheem
+3  A: 

No, setnextevent is the ONLY method in 3.0 that should be used, the other ones setnextRoute and relocate() are now deprecated.

If you made a change to the Route.cfm, make sure you reinitialize the application for the changes to take effect.

index.cfm?fwreinit=1

Usually they forget to reinit the app if a change is made.

Luis Majano