The views compose the visual part or “screens” of the application. One thing to keep in mind is the difference between a View and a Layout. Usually, on every page of an application or a website there are certain elements that remain consistent across all pages, for example, a navigation menu, a logotype, a footer, etc; and there are also parts of the screen that change from page to page. The Layout of the page includes all the constant elements, while the View is the part that is different from page to page.
A View is always contained within a Layout.
Views are ColdFusion templates that handle mainly output of variables and the rendering of the user interface of the application. All views are stored within the “views” directory. Views can also be grouped in folders within this directory.
The view to display is always set at the event handler level. To set a view an event handler must call the setView() method. It is only necessary to indicate the file name of the view without the ".cfm" extension. For example to set the view vwMain.cfm use setView(“vwMain”). For views contained in subfolders use the path to the view template. I.e. setView(“users/vwEdit”) will set the view template to be /views/users/vwEdit.cfm.
The code within a view usually needs to have access to variables set within an event handler. To do this, use the request.requestState structure. This structure will contain all values set by the event handler using the setValue() function in the form of keys of the structure.
Views in External Modules:
When executing an event handler within an external module, all views are relative to the views directory of the module. This means that event handlers in external modules can only render their own views.
