coldbox.system.web.context

Class RequestContext

railo-context.Component
        extended by coldbox.system.web.context.RequestContext
Class Attributes:
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • serializable : false
  •  
    Direct Known Subclasses:
    RequestContextDecorator

    Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.coldbox.org | www.luismajano.com | www.ortussolutions.com Models a ColdBox request, stores the incoming request collection and private request collection. It is also used to determine metadata about a request and helps you build RESTFul responses.

    Property Summary
    type property default serializable required
    struct context
          The request context.

    true false
    any controller
          ColdBox Controller.

    true false
    struct privateContext
          The private request context.

    true false
    any properties
          ColdBox System Properties.

    true false
    Constructor Summary
    init(struct properties='[runtime expression]', any controller)
          Constructor.
    Method Summary
    string buildLink(any linkTo, [boolean translate='true'], [boolean ssl], [any baseURL=''], [any queryString=''])
         Builds a link to a passed event, either SES or normal link.
    any clearCollection([boolean private='false'])
         Clears the entire collection.
    any clearPrivateCollection()
         Clears the private collection.
    any collectionAppend(struct collection, [boolean overwrite='false'], [boolean private='false'])
         Append a structure to the collection, with overwrite or not.
    struct getCollection([boolean deepCopy='false'], [boolean private='false'])
         I Get a reference or deep copy of the public or private request Collection.
    string getContext()
         get: The request context.
    string getController()
         get: ColdBox Controller.
    string getCurrentAction()
         Gets the current action requested in the current event.
    string getCurrentEvent()
         Gets the current incoming event.
    string getCurrentHandler()
         Gets the current handler requested in the current event.
    string getCurrentLayout()
         Gets the current set layout for rendering.
    string getCurrentLayoutModule()
         Gets the current set layout's module for rendering.
    string getCurrentModule()
         Gets the current module name, else returns empty string.
    string getCurrentRoute()
         Get the current request's SES route that matched.
    string getCurrentRoutedNamespace()
         Get the current routed namespace that matched the SES route, if any.
    string getCurrentRoutedURL()
         Get the current routed URL that matched the SES route.
    string getCurrentView()
         Gets the current set view the framework will try to render for this request.
    struct getCurrentViewArgs()
         Gets the current set view the framework will try to render for this request.
    string getCurrentViewModule()
         Gets the current set views's module for rendering.
    string getDefaultLayout()
         Get's the default layout of the application.
    string getDefaultView()
         Get's the default view of the application.
    struct getEventCacheableEntry()
         Get the event cacheable entry.
    any getEventName()
         Get the event name.
    struct getFolderLayouts()
         Get the registered folder layout associations map.
    struct getHTTPBasicCredentials()
         Returns the username and password sent via HTTP basic authentication.
    any getHTTPContent([boolean json='false'], [boolean xml='false'])
         Get the raw HTTP content.
    any getHTTPHeader(any The header to get, [any defaultValue=''])
         Get an HTTP header.
    string getHTTPMethod()
         Get the HTTP Request Method Type.
    struct getMemento()
         Get a representation of this instance.
    string getModuleRoot([any module=''])
         Convenience method to get the current request's module root path.
    struct getPrivateCollection([boolean deepCopy='false'])
         I get a private collection.
    string getPrivateContext()
         get: The private request context.
    numeric getPrivateSize()
         Get the private collection Size.
    any getPrivateTrimValue(any name, [any defaultValue])
         Get a trim value from the private request collection.
    any getPrivateValue(any name, [any defaultValue])
         Get a value from the private request collection.
    string getProperties()
         get: ColdBox System Properties.
    struct getRegisteredLayouts()
         Get all the registered layouts in the configuration file.
    struct getRenderData()
         Get the renderData structure.
    struct getRoutedStruct()
         Get the routed structure of key-value pairs.
    string getSelf()
         Returns index.
    string getSESBaseURL()
         Get the SES base URL for this request.
    numeric getSize([boolean private='false'])
         Get the collection Size.
    any getTrimValue(any name, [any defaultValue], [boolean private='false'])
         Get a value from the request collection and if simple value, I will trim it.
    any getValue(any name, [any defaultValue], [boolean private='false'])
         Get a value from the public or private request collection.
    struct getViewCacheableEntry()
         Get the event cacheable entry.
    struct getViewLayouts()
         Get the registered view layout associations map.
    boolean isAjax()
         Determines if in an Ajax call or not by looking at the request headers.
    boolean isEventCacheable()
         Check wether the incoming event has been flagged for caching.
    boolean isNoExecution()
         Determine if we need to execute an incoming event or not.
    boolean isNoRender()
         Is this a no render request.
    boolean isProxyRequest()
         Is this a coldbox proxy request.
    boolean isSES()
         Is this request in SES mode.
    boolean isSSL()
         Are we in SSL or not? This method looks at cgi.
    boolean isViewCacheable()
         Check wether the incoming view has been flagged for caching.
    any noExecution()
         Set that the request will not execute an incoming event.
    any noLayout()
         Mark this request to not use a layout for rendering.
    any noRender([boolean remove='false'])
         Set the flag that tells the framework not to render, just execute.
    any overrideEvent(any event)
         Override the current event in the request collection.
    any paramPrivateValue(any name, any value)
         Just like cfparam, but for the private request collection.
    any paramValue(any name, any value, [boolean private='false'])
         Just like cfparam, but for the request collection.
    any privateCollectionAppend(struct collection, [boolean overwrite='false'])
         Append a structure to the collection, with overwrite or not.
    boolean privateValueExists(any name)
         Check if a value exists in the private request collection.
    any removeEventCacheableEntry()
         Check wether the incoming event has been flagged for caching.
    any removePrivateValue(any name, [boolean private='false'])
         remove a value in the private request collection.
    any removeValue(any name, [boolean private='false'])
         remove a value in the request collection.
    any renderData([any type='HTML'], any data, [any contentType=''], [any encoding='utf-8'], [numeric statusCode='200'], [any statusText=''], [any location=''], [any jsonCallback=''], [any jsonQueryFormat='query'], [boolean jsonAsText='false'], [any xmlColumnList=''], [boolean xmlUseCDATA='false'], [any xmlListDelimiter=','], [any xmlRootName=''], [struct pdfArgs='[runtime expression]'], [any formats=''], [any formatsView=''], [boolean isBinary='false'])
         Use this method to tell the framework to render data for you.
    private any renderWithFormats()
         Render data with formats.
    any setContext(struct context)
         set: The request context.
    any setController(any controller)
         set: ColdBox Controller.
    any setDefaultLayout(any defaultLayout)
         Override the default layout for a request.
    any setDefaultView(any defaultView)
         Override the default view for a request.
    any setEventCacheableEntry(struct cacheEntry)
         Check wether the incoming event has been flagged for caching.
    any setHTTPHeader([any statusCode], [any statusText=''], [any name], [any value=''])
         Set an HTTP Header.
    any setIsSES(boolean isSES)
         Is this request in SES mode.
    any setLayout(any name, [any module=''])
         Set the layout to override and render.
    any setMemento(struct memento)
         Override the instance.
    any setPrivateContext(struct privateContext)
         set: The private request context.
    any setPrivateValue(any name, any value)
         Set a value in the private request collection.
    any setProperties(any properties)
         set: ColdBox System Properties.
    any setProxyRequest()
         Set that this is a proxy request.
    any setRoutedStruct(struct routedStruct)
         Get the routed structure of key-value pairs.
    any setSESBaseURL(string sesBaseURL)
         Set the ses base URL for this request.
    any setValue(any name, any value, [boolean private='false'])
         Set a value in the request collection.
    any setView([any view], [struct args='[runtime expression]'], [any layout], [any module=''], [boolean noLayout='false'], [boolean cache='false'], [any cacheTimeout=''], [any cacheLastAccessTimeout=''], [any cacheSuffix=''], [any cacheProvider='template'])
         Set the view to render in this request.
    any setViewCacheableEntry(struct cacheEntry)
         Set the view cacheable entry.
    boolean valueExists(any name, [boolean private='false'])
         Check if a value exists in the request collection.
     
    Methods inherited from class railo-context.Component
    None

    Constructor Detail

    init

    public init(struct properties='[runtime expression]', any controller)

    Constructor

    Parameters:
    properties - The ColdBox application settings
    controller - Acess to the system controller

    Property Detail

    context

    property struct context

    The request context

    Attributes:
    required - false
    serializable - true

    controller

    property any controller

    ColdBox Controller

    Attributes:
    required - false
    serializable - true

    privateContext

    property struct privateContext

    The private request context

    Attributes:
    required - false
    serializable - true

    properties

    property any properties

    ColdBox System Properties

    Attributes:
    required - false
    serializable - true

    Method Detail

    buildLink

    public string buildLink(any linkTo, [boolean translate='true'], [boolean ssl], [any baseURL=''], [any queryString=''])

    Builds a link to a passed event, either SES or normal link. If the ses interceptor is declared it will create routes

    Parameters:
    linkTo - The event or route you want to create the link to
    translate - Translate between . and / depending on the ses mode. So you can just use dot notation
    ssl - Turn SSl on/off on URL creation
    baseURL - If not using SES, you can use this argument to create your own base url apart from the default of index.cfm. Example: https://mysample.com/index.cfm
    queryString - The query string to append

    clearCollection

    public any clearCollection([boolean private='false'])

    Clears the entire collection

    Parameters:
    private - Use public or private request collection

    clearPrivateCollection

    public any clearPrivateCollection()

    Clears the private collection


    collectionAppend

    public any collectionAppend(struct collection, [boolean overwrite='false'], [boolean private='false'])

    Append a structure to the collection, with overwrite or not. Overwrite = false by default

    Parameters:
    collection - The collection to incorporate
    overwrite - Overwrite elements, defaults to false
    private - Private or public, defaults public.

    getCollection

    public struct getCollection([boolean deepCopy='false'], [boolean private='false'])

    I Get a reference or deep copy of the public or private request Collection

    Parameters:
    deepCopy - Default is false, gives a reference to the collection. True, creates a deep copy of the collection.
    private - Use public or private request collection

    getContext

    public string getContext()

    get: The request context


    getController

    public string getController()

    get: ColdBox Controller


    getCurrentAction

    public string getCurrentAction()

    Gets the current action requested in the current event


    getCurrentEvent

    public string getCurrentEvent()

    Gets the current incoming event


    getCurrentHandler

    public string getCurrentHandler()

    Gets the current handler requested in the current event


    getCurrentLayout

    public string getCurrentLayout()

    Gets the current set layout for rendering


    getCurrentLayoutModule

    public string getCurrentLayoutModule()

    Gets the current set layout's module for rendering


    getCurrentModule

    public string getCurrentModule()

    Gets the current module name, else returns empty string


    getCurrentRoute

    public string getCurrentRoute()

    Get the current request's SES route that matched


    getCurrentRoutedNamespace

    public string getCurrentRoutedNamespace()

    Get the current routed namespace that matched the SES route, if any


    getCurrentRoutedURL

    public string getCurrentRoutedURL()

    Get the current routed URL that matched the SES route


    getCurrentView

    public string getCurrentView()

    Gets the current set view the framework will try to render for this request


    getCurrentViewArgs

    public struct getCurrentViewArgs()

    Gets the current set view the framework will try to render for this request


    getCurrentViewModule

    public string getCurrentViewModule()

    Gets the current set views's module for rendering


    getDefaultLayout

    public string getDefaultLayout()

    Get's the default layout of the application


    getDefaultView

    public string getDefaultView()

    Get's the default view of the application


    getEventCacheableEntry

    public struct getEventCacheableEntry()

    Get the event cacheable entry


    getEventName

    public any getEventName()

    Get the event name


    getFolderLayouts

    public struct getFolderLayouts()

    Get the registered folder layout associations map


    getHTTPBasicCredentials

    public struct getHTTPBasicCredentials()

    Returns the username and password sent via HTTP basic authentication


    getHTTPContent

    public any getHTTPContent([boolean json='false'], [boolean xml='false'])

    Get the raw HTTP content

    Parameters:
    json - Try to return the content as deserialized json
    xml - Try to return the content as an XML object

    getHTTPHeader

    public any getHTTPHeader(any The header to get, [any defaultValue=''])

    Get an HTTP header

    Parameters:
    The header to get
    defaultValue - The default value if not found

    getHTTPMethod

    public string getHTTPMethod()

    Get the HTTP Request Method Type


    getMemento

    public struct getMemento()

    Get a representation of this instance


    getModuleRoot

    public string getModuleRoot([any module=''])

    Convenience method to get the current request's module root path. If no module, then returns empty path. You can also get this from the modules settings

    Parameters:
    module - Optional name of the module you want the root for, defaults to the current running module

    getPrivateCollection

    public struct getPrivateCollection([boolean deepCopy='false'])

    I get a private collection

    Parameters:
    deepCopy - Default is false, gives a reference to the collection. True, creates a deep copy of the collection.

    getPrivateContext

    public string getPrivateContext()

    get: The private request context


    getPrivateSize

    public numeric getPrivateSize()

    Get the private collection Size


    getPrivateTrimValue

    public any getPrivateTrimValue(any name, [any defaultValue])

    Get a trim value from the private request collection.

    Parameters:
    name - The key name
    defaultValue - default value

    getPrivateValue

    public any getPrivateValue(any name, [any defaultValue])

    Get a value from the private request collection.

    Parameters:
    name - The key name
    defaultValue - default value

    getProperties

    public string getProperties()

    get: ColdBox System Properties


    getRegisteredLayouts

    public struct getRegisteredLayouts()

    Get all the registered layouts in the configuration file


    getRenderData

    public struct getRenderData()

    Get the renderData structure


    getRoutedStruct

    public struct getRoutedStruct()

    Get the routed structure of key-value pairs. What the ses interceptor could match.


    getSelf

    public string getSelf()

    Returns index.cfm?{eventName}=


    getSESBaseURL

    public string getSESBaseURL()

    Get the SES base URL for this request

    Returns:
    RequestContext

    getSize

    public numeric getSize([boolean private='false'])

    Get the collection Size

    Parameters:
    private - Private or public, defaults public.

    getTrimValue

    public any getTrimValue(any name, [any defaultValue], [boolean private='false'])

    Get a value from the request collection and if simple value, I will trim it.

    Parameters:
    name - The key name
    defaultValue - default value
    private - Private or public, defaults public.

    getValue

    public any getValue(any name, [any defaultValue], [boolean private='false'])

    Get a value from the public or private request collection.

    Parameters:
    name - The key name
    defaultValue - default value
    private - Private or public, defaults public.

    getViewCacheableEntry

    public struct getViewCacheableEntry()

    Get the event cacheable entry


    getViewLayouts

    public struct getViewLayouts()

    Get the registered view layout associations map


    isAjax

    public boolean isAjax()

    Determines if in an Ajax call or not by looking at the request headers


    isEventCacheable

    public boolean isEventCacheable()

    Check wether the incoming event has been flagged for caching


    isNoExecution

    public boolean isNoExecution()

    Determine if we need to execute an incoming event or not


    isNoRender

    public boolean isNoRender()

    Is this a no render request


    isProxyRequest

    public boolean isProxyRequest()

    Is this a coldbox proxy request


    isSES

    public boolean isSES()

    Is this request in SES mode


    isSSL

    public boolean isSSL()

    Are we in SSL or not? This method looks at cgi.server_port_secure for indication


    isViewCacheable

    public boolean isViewCacheable()

    Check wether the incoming view has been flagged for caching


    noExecution

    public any noExecution()

    Set that the request will not execute an incoming event. Most likely simulating a servlet call

    Returns:
    RequestContext

    noLayout

    public any noLayout()

    Mark this request to not use a layout for rendering

    Returns:
    RequestContext

    noRender

    public any noRender([boolean remove='false'])

    Set the flag that tells the framework not to render, just execute

    Parameters:
    remove - Remove the flag completely
    Returns:
    RequestContext

    overrideEvent

    public any overrideEvent(any event)

    Override the current event in the request collection. This method does not execute the event, it just replaces the event to be executed by the framework's RunEvent() method. This method is usually called from an onRequestStart or onApplicationStart method

    Parameters:
    event - The event to override with
    Returns:
    RequestContext

    paramPrivateValue

    public any paramPrivateValue(any name, any value)

    Just like cfparam, but for the private request collection

    Parameters:
    name - The key name
    value - The value
    Returns:
    RequestContext

    paramValue

    public any paramValue(any name, any value, [boolean private='false'])

    Just like cfparam, but for the request collection

    Parameters:
    name - The key name
    value - The value
    private - Private or public, defaults public.
    Returns:
    RequestContext

    privateCollectionAppend

    public any privateCollectionAppend(struct collection, [boolean overwrite='false'])

    Append a structure to the collection, with overwrite or not. Overwrite = false by default

    Parameters:
    collection - The collection to incorporate
    overwrite - Overwrite elements, defaults to false

    privateValueExists

    public boolean privateValueExists(any name)

    Check if a value exists in the private request collection

    Parameters:
    name - The key name

    removeEventCacheableEntry

    public any removeEventCacheableEntry()

    Check wether the incoming event has been flagged for caching

    Returns:
    RequestContext

    removePrivateValue

    public any removePrivateValue(any name, [boolean private='false'])

    remove a value in the private request collection

    Parameters:
    name - The key name
    private
    Returns:
    RequestContext

    removeValue

    public any removeValue(any name, [boolean private='false'])

    remove a value in the request collection

    Parameters:
    name - The key name
    private - Private or public, defaults public.
    Returns:
    RequestContext

    renderData

    public any renderData([any type='HTML'], any data, [any contentType=''], [any encoding='utf-8'], [numeric statusCode='200'], [any statusText=''], [any location=''], [any jsonCallback=''], [any jsonQueryFormat='query'], [boolean jsonAsText='false'], [any xmlColumnList=''], [boolean xmlUseCDATA='false'], [any xmlListDelimiter=','], [any xmlRootName=''], [struct pdfArgs='[runtime expression]'], [any formats=''], [any formatsView=''], [boolean isBinary='false'])

    Use this method to tell the framework to render data for you. The framework will take care of marshalling the data for you

    Parameters:
    type - The type of data to render. Valid types are JSON, JSONP, JSONT, XML, WDDX, PLAIN/HTML, TEXT, PDF. The deafult is HTML or PLAIN. If an invalid type is sent in, this method will throw an error
    data - The data you would like to marshall and return by the framework
    contentType - The content type of the data. This will be used in the cfcontent tag: text/html, text/plain, text/xml, text/json, etc. The default value is text/html. However, if you choose JSON this method will choose application/json, if you choose WDDX or XML this method will choose text/xml for you.
    encoding - The default character encoding to use. The default encoding is utf-8
    statusCode - The HTTP status code to send to the browser. Defaults to 200
    statusText - Explains the HTTP status code sent to the browser.
    location - Optional argument used to set the HTTP Location header
    jsonCallback - Only needed when using JSONP, this is the callback to add to the JSON packet
    jsonQueryFormat - JSON Only: query or array format for encoding. The default is CF query standard
    jsonAsText - If set to false, defaults content mime-type to application/json, else will change encoding to plain/text
    xmlColumnList - XML Only: Choose which columns to inspect, by default it uses all the columns in the query, if using a query
    xmlUseCDATA - XML Only: Use CDATA content for ALL values. The default is false
    xmlListDelimiter - XML Only: The delimiter in the list. Comma by default
    xmlRootName - XML Only: The name of the initial root element of the XML packet
    pdfArgs - All the PDF arguments to pass along to the CFDocument tag.
    formats - The formats list or array that ColdBox should respond to using the passed in data argument. You can pass any of the valid types (JSON,JSONP,JSONT,XML,WDDX,PLAIN,HTML,TEXT,PDF). For PDF and HTML we will try to render the view by convention based on the incoming event
    formatsView - The view that should be used for rendering HTML/PLAIN/PDF. By default ColdBox uses the name of the event as an implicit view
    isBinary - Bit that determines if the data being set for rendering is binary or not.

    renderWithFormats

    private any renderWithFormats()

    Render data with formats


    setContext

    public any setContext(struct context)

    set: The request context

    Parameters:
    context

    setController

    public any setController(any controller)

    set: ColdBox Controller

    Parameters:
    controller

    setDefaultLayout

    public any setDefaultLayout(any defaultLayout)

    Override the default layout for a request

    Parameters:
    defaultLayout
    Returns:
    RequestContext

    setDefaultView

    public any setDefaultView(any defaultView)

    Override the default view for a request

    Parameters:
    defaultView
    Returns:
    RequestContext

    setEventCacheableEntry

    public any setEventCacheableEntry(struct cacheEntry)

    Check wether the incoming event has been flagged for caching

    Parameters:
    cacheEntry - The md entry for caching
    Returns:
    RequestContext

    setHTTPHeader

    public any setHTTPHeader([any statusCode], [any statusText=''], [any name], [any value=''])

    Set an HTTP Header return RequestContext

    Parameters:
    statusCode - the status code
    statusText - the status text
    name - The header name
    value - The header value

    setIsSES

    public any setIsSES(boolean isSES)

    Is this request in SES mode

    Parameters:
    isSES
    Returns:
    RequestContext

    setLayout

    public any setLayout(any name, [any module=''])

    Set the layout to override and render. Layouts are pre-defined in the config file. However I can override these settings if needed. Do not append a the cfm extension. Private Request Collection name

    Parameters:
    name - The name of the layout to set
    module - The module to use

    setMemento

    public any setMemento(struct memento)

    Override the instance

    Parameters:
    memento

    setPrivateContext

    public any setPrivateContext(struct privateContext)

    set: The private request context

    Parameters:
    privateContext

    setPrivateValue

    public any setPrivateValue(any name, any value)

    Set a value in the private request collection

    Parameters:
    name - The key name
    value - The value
    Returns:
    RequestContext

    setProperties

    public any setProperties(any properties)

    set: ColdBox System Properties

    Parameters:
    properties

    setProxyRequest

    public any setProxyRequest()

    Set that this is a proxy request

    Returns:
    RequestContext

    setRoutedStruct

    public any setRoutedStruct(struct routedStruct)

    Get the routed structure of key-value pairs. What the ses interceptor could match.

    Parameters:
    routedStruct
    Returns:
    RequestContext

    setSESBaseURL

    public any setSESBaseURL(string sesBaseURL)

    Set the ses base URL for this request

    Parameters:
    sesBaseURL
    Returns:
    RequestContext

    setValue

    public any setValue(any name, any value, [boolean private='false'])

    Set a value in the request collection

    Parameters:
    name - The key name
    value - The value
    private - Private or public, defaults public.
    Returns:
    RequestContext

    setView

    public any setView([any view], [struct args='[runtime expression]'], [any layout], [any module=''], [boolean noLayout='false'], [boolean cache='false'], [any cacheTimeout=''], [any cacheLastAccessTimeout=''], [any cacheSuffix=''], [any cacheProvider='template'])

    Set the view to render in this request. Private Request Collection Name: currentView, currentLayout

    Parameters:
    view - The name of the view to set. If a layout has been defined it will assign it, else if will assign the default layout. No extension please
    args - An optional set of arguments that will be available when the view is rendered
    layout - You can override the rendering layout of this setView() call if you want to. Else it defaults to implicit resolution or another override.
    module - The explicit module view
    noLayout - Boolean flag, wether the view sent in will be using a layout or not. Default is false. Uses a pre set layout or the default layout.
    cache - True if you want to cache the rendered view.
    cacheTimeout - The cache timeout in minutes
    cacheLastAccessTimeout - The last access timeout in minutes
    cacheSuffix - Add a cache suffix to the view cache entry. Great for multi-domain caching or i18n caching.
    cacheProvider - The cache provider you want to use for storing the rendered view. By default we use the 'template' cache provider
    Returns:
    RequestContext

    setViewCacheableEntry

    public any setViewCacheableEntry(struct cacheEntry)

    Set the view cacheable entry

    Parameters:
    cacheEntry - The md entry for caching
    Returns:
    RequestContext

    valueExists

    public boolean valueExists(any name, [boolean private='false'])

    Check if a value exists in the request collection

    Parameters:
    name - The key name
    private - Private or public, defaults public.