ViewManager

Package: MachII.framework
Manages registered views for the framework.

<!--- License: Copyright 2006 Mach-II Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright: Mach-II Corporation Author: Ben Edwards (ben@ben-edwards.com) $Id: ViewManager.cfc 4466 2006-09-15 16:43:50Z pfarrell $ Created version: 1.0.0 Updated version: 1.1.1 --->

Method Summary
public void init(string configXML, AppManager appManager)

Initialization function called by the framework.

public void configure()

Prepares the manager for use.

public AppManager getAppManager()
public string getViewPath(string viewName)

Gets the view path.

public boolean isViewDefined(string viewName)

Checks if the view is defined.

public void setAppManager(AppManager appManager)
Method Detail
configure

public void configure( )

Prepares the manager for use.

Parameters:

Code:

	<cffunction name="configure" access="public" returntype="void"
		hint="Prepares the manager for use.">
		
	</cffunction> 

getAppManager

public AppManager getAppManager( )

Parameters:

Code:

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

getViewPath

public string getViewPath( string viewName )

Gets the view path.

Parameters:
string viewName

Code:

	<cffunction name="getViewPath" access="public" returntype="string" output="false"
		hint="Gets the view path.">
		<cfargument name="viewName" type="string" required="true"
			hint="Name of the view path to get." />
		
		<cfif isViewDefined(arguments.viewName)>
			<cfreturn variables.viewPaths[arguments.viewName] />
		<cfelse>
			<cfthrow type="MachII.framework.ViewNotDefined" 
				message="View with name '#arguments.viewName#' is not defined." />
		</cfif>
	</cffunction> 

init

public void init( string configXML, AppManager appManager )

Initialization function called by the framework.

Parameters:
string configXML
AppManager appManager

Code:

	<cffunction name="init" access="public" returntype="void" output="false"
		hint="Initialization function called by the framework.">
		<cfargument name="configXML" type="string" required="true" />
		<cfargument name="appManager" type="MachII.framework.AppManager" required="true" />
		
		<cfset var viewNodes = "" />
		<cfset var name = "" />
		<cfset var page = "" />
		<cfset var i = 0 />
		
		<cfset setAppManager(arguments.appManager) />

		
		<cfset viewNodes = XMLSearch(configXML,"//page-views/page-view") />
		<cfloop from="1" to="#ArrayLen(viewNodes)#" index="i">
			<cfset name = viewNodes[i].xmlAttributes['name'] />
			<cfset page = viewNodes[i].xmlAttributes['page'] />
			
			<cfset variables.viewPaths[name] = page />
		</cfloop> 
	</cffunction> 

isViewDefined

public boolean isViewDefined( string viewName )

Checks if the view is defined.

Parameters:
string viewName

Code:

	<cffunction name="isViewDefined" access="public" returntype="boolean" output="false"
		hint="Checks if the view is defined.">
		<cfargument name="viewName" type="string" required="true"
			hint="Name of the view to check." />
		<cfreturn StructKeyExists(variables.viewPaths, arguments.viewName) />
	</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>