Relocating
The framework provides you with the relocate() method that you can use to relocate to other events thanks to the framework super type object, the grand daddy of all things ColdBox.
Please see the Super Type CFC Docs for further investigation of all the goodness of methods you have available.
1
/**
2
* Relocate user browser requests to other events, URLs, or URIs.
3
*
4
* @event The name of the event to run, if not passed, then it will use the default event found in your configuration file
5
* @URL The full URL you would like to relocate to instead of an event: ex: URL='http://www.google.com'
6
* @URI The relative URI you would like to relocate to instead of an event: ex: URI='/mypath/awesome/here'
7
* @queryString The query string to append, if needed. If in SES mode it will be translated to convention name value pairs
8
* @persist What request collection keys to persist in flash ram
9
* @persistStruct A structure key-value pairs to persist in flash ram
10
* @addToken Whether to add the tokens or not. Default is false
11
* @ssl Whether to relocate in SSL or not
12
* @baseURL Use this baseURL instead of the index.cfm that is used by default. You can use this for ssl or any full base url you would like to use. Ex: https://mysite.com/index.cfm
13
* @postProcessExempt Do not fire the postProcess interceptors
14
* @statusCode The status code to use in the relocation
15
*/
16
void function relocate(
17
event,
18
URL,
19
URI,
20
queryString,
21
persist,
22
struct persistStruct,
23
boolean addToken,
24
boolean ssl,
25
baseURL,
26
boolean postProcessExempt,
27
numeric statusCode
28
)
Copied!
It is extremely important that you use this method when relocating instead of the native ColdFusion methods as it allows you to gracefully relocate to other events or external URIs. By graceful, we mean it does a lot more behind the scenes like making sure the flash scope is persisted, logging, post processing interceptions can occur and safe relocations.
So always remember that you relocate via relocate() and if I asked you: "Where in the world does event handlers get this method from?", you need to answer: "From the super typed inheritance".
1
relocate( "home" );
2
relocate( event="shop", ssl=true );
3
relocate( event="user.view", queryString="id=#rc.id#" );
4
relocate( url="http://www.google.com" );
5
relocate( uri="/docs/index.html" )
Copied!
Last modified 2mo ago
Copy link
Edit on GitHub