ViewContext

Package: MachII.framework
Handles view display for an EventContext.
Method Summary
public void init(AppManager appManager)
public void displayView(Event event, string viewName, [string contentKey=""], [boolean append="false"])
public AppManager getAppManager()
private string getAppRoot()
private string getFullPath(string viewName)
public any getProperty(string propertyName)

Gets the specified property - this is just a shortcut for getAppManager().getPropertyManager().getProperty()

public void setAppManager(AppManager appManager)
public any setProperty(string propertyName, any propertyValue)

Sets the specified property - this is just a shortcut for getAppManager().getPropertyManager().setProperty()

Method Detail
displayView

public void displayView( Event event, string viewName, [string contentKey=""], [boolean append="false"] )

Parameters:
Event event
string viewName
[string contentKey=""]
[boolean append="false"]

Code:

	<cffunction name="displayView" access="public" returntype="void" output="true">
		<cfargument name="event" type="MachII.framework.Event" required="true" />
		<cfargument name="viewName" type="string" required="true" />
		<cfargument name="contentKey" type="string" required="false" default="" />
		<cfargument name="append" type="boolean" required="false" default="false" />
		
		<cfset var viewPath = getFullPath(arguments.viewName) />
		<cfset var viewContent = "" />
		<cfset request.event = arguments.event />

		<cfif arguments.contentKey is not ''>
			<cfsavecontent variable="viewContent">
				<cfinclude template="#viewPath#" />
			</cfsavecontent>
			<cfif arguments.append and isDefined(arguments.contentKey)>
				<cfset viewContent = evaluate(arguments.contentKey) & viewContent />
			</cfif>
			<cfset setVariable(arguments.contentKey,viewContent) />
		<cfelse>
			<cfinclude template="#viewPath#" />
		</cfif>
	</cffunction> 

getAppManager

public AppManager getAppManager( )

Parameters:

Code:

	<cffunction name="getAppManager" access="public" returntype="MachII.framework.AppManager" output="false">
		<cfreturn variables.appManager />
	</cffunction> 

getAppRoot

private string getAppRoot( )

Parameters:

Code:

	<cffunction name="getAppRoot" access="private" returntype="string" output="false">
		<cfreturn getAppManager().getPropertyManager().getProperty('applicationRoot') />
	</cffunction> 

getFullPath

private string getFullPath( string viewName )

Parameters:
string viewName

Code:

	<cffunction name="getFullPath" access="private" returntype="string" output="false">
		<cfargument name="viewName" type="string" required="true" />
		
		<cfset var viewPath = getAppManager().getViewManager().getViewPath(arguments.viewName) />
		<cfreturn getAppRoot() & viewPath />
	</cffunction> 

getProperty

public any getProperty( string propertyName )

Gets the specified property - this is just a shortcut for getAppManager().getPropertyManager().getProperty()

Parameters:
string propertyName

Code:

	<cffunction name="getProperty" access="public" returntype="any" output="false"
		hint="Gets the specified property - this is just a shortcut for getAppManager().getPropertyManager().getProperty()">
		<cfargument name="propertyName" type="string" required="yes"
			hint="The name of the property to return"/>
		<cfif not structKeyExists(variables,"propMgr")>
			<cfset variables.propMgr = getAppManager().getPropertyManager()/>
		</cfif>
		<cfreturn variables.propMgr.getProperty(arguments.propertyName) />
	</cffunction> 

init

public void init( AppManager appManager )

Parameters:
AppManager appManager

Code:

	<cffunction name="init" access="public" returntype="void" output="false">
		<cfargument name="appManager" type="MachII.framework.AppManager" required="true" />
		<cfset setAppManager(arguments.appManager) />
	</cffunction> 

setAppManager

public void setAppManager( AppManager appManager )

Parameters:
AppManager appManager

Code:

	<cffunction name="setAppManager" access="public" returntype="void" output="false">
		<cfargument name="appManager" type="MachII.framework.AppManager" required="true" />
		<cfset variables.appManager = arguments.appManager />
	</cffunction> 

setProperty

public any setProperty( string propertyName, any propertyValue )

Sets the specified property - this is just a shortcut for getAppManager().getPropertyManager().setProperty()

Parameters:
string propertyName
any propertyValue

Code:

	<cffunction name="setProperty" access="public" returntype="any" output="false"
		hint="Sets the specified property - this is just a shortcut for getAppManager().getPropertyManager().setProperty()">
		<cfargument name="propertyName" type="string" required="yes"
			hint="The name of the property to set"/>
		<cfargument name="propertyValue" type="any" required="yes" 
			hint="The value to store in the property" />
		<cfif not structKeyExists(variables,"propMgr")>
			<cfset variables.propMgr = getAppManager().getPropertyManager()/>
		</cfif>
		<cfreturn variables.propMgr.setProperty(arguments.propertyName, arguments.propertyValue) />
	</cffunction>