faqListener

Package: machii_info_sample.controllers
Inherits from: MachII.framework.Listener
I am the listener for faqs
Method Summary
public void configure()

I initialize this listener as part of the framework startup.

public void createFaq(Event event)

I cause faq to be created from the current event object.

public void deleteFaq(Event event)

I cause a faq to be deleted.

public query getAllFaqs()

I return a query containing all of the faqs.

public faq getFaqById(Event event)

I return a single faq identified by it's ID

public query getFaqsByCategoryID(Event event)

I return a query containing faqs for a given categoryID

public query getLatestFaqs()

I return a query of the latest faqs

public query getUnpublishedFaqs()

I return a query of the unpublished faqs

public void updateFaq(Event event)

I cause a faq to be updated from the current event object.

Method Detail
configure

public void configure( )

I initialize this listener as part of the framework startup.

Parameters:

Code:

	<cffunction name="configure" access="public" returntype="void" output="true" displayname="Listener Constructor" hint="I initialize this listener as part of the framework startup.">				
		<cfscript>			
			var appConstants = getAppManager().getPropertyManager().getProperty("appConstants");
	        var dsn = appConstants.getDsn(); 
			var dbType = appConstants.getDbType(); 			
			variables.faqGateway = createObject("component","machii_info_sample.model.faq.faqGateway").init(dsn);
			variables.faqDAO = CreateObject("component", "machii_info_sample.model.dao.DAOFactory").init(dsn, "machii_info").getDAOFactory(dbType).getFaqDAO();
		</cfscript>					
	</cffunction> 

createFaq

public void createFaq( Event event )

I cause faq to be created from the current event object.

Parameters:
Event event

Code:

	<cffunction name="createFaq" access="public" returntype="void" output="false" displayname="Create Faq" hint="I cause faq to be created from the current event object.">
		<cfargument name="event" type="MachII.framework.Event" required="yes" displayname="Event" hint="I am the current event" />
		<cfset var faq = arguments.event.getArg("faq") />
		<cfset variables.faqDAO.create(faq) /> 
	</cffunction> 

deleteFaq

public void deleteFaq( Event event )

I cause a faq to be deleted.

Parameters:
Event event

Code:

	<cffunction name="deleteFaq" access="public" returntype="void" output="false" displayname="Delete Faq" hint="I cause a faq to be deleted.">
		<cfargument name="event" type="MachII.framework.Event" required="yes" displayname="Event" hint="I am the current event" />		
		<cfset var faq = arguments.event.getArg("faq") />
		<cfset variables.faqDAO.delete(faq) />	 
	</cffunction> 

getAllFaqs

public query getAllFaqs( )

I return a query containing all of the faqs.

Parameters:

Code:

	<cffunction name="getAllFaqs" access="public" returntype="query" output="false" displayname="Get All Faqs" hint="I return a query containing all of the faqs.">
		<cfreturn variables.faqGateway.findAll() />
	</cffunction> 

getFaqById

public faq getFaqById( Event event )

I return a single faq identified by it's ID

Parameters:
Event event

Code:

	<cffunction name="getFaqById" access="public" returntype="machii_info_sample.model.faq.faq" output="false" displayname="Get faq By ID" hint="I return a single faq identified by it's ID">
		<cfargument name="event" type="MachII.framework.Event" required="yes" displayname="Event" hint="I am the current event." /> 
		<cfset var faqID = arguments.event.getArg("faqid") />
		<cfset var faq = createObject("component","machii_info_sample.model.faq.faq").init() />		
		<cfset variables.faqDAO.read(faq, faqID) />
		<cfreturn faq />
	</cffunction> 

getFaqsByCategoryID

public query getFaqsByCategoryID( Event event )

I return a query containing faqs for a given categoryID

Parameters:
Event event

Code:

	<cffunction name="getFaqsByCategoryID" access="public" returntype="query" output="false" displayname="Get Faqs By categoryID" hint="I return a query containing faqs for a given categoryID">
		<cfargument name="event" type="MachII.framework.Event" required="yes" displayname="Event" hint="I am the current event." /> 
		<cfset var categoryID = arguments.event.getArg("categoryid") />
		<cfreturn variables.faqGateway.findFaqs(categoryID) />
	</cffunction> 

getLatestFaqs

public query getLatestFaqs( )

I return a query of the latest faqs

Parameters:

Code:

	<cffunction name="getLatestFaqs" access="public" returntype="query" output="false" displayname="Get Latest Faqs" hint="I return a query of the latest faqs">
		<cfreturn variables.faqGateway.findLatest() />
	</cffunction> 

getUnpublishedFaqs

public query getUnpublishedFaqs( )

I return a query of the unpublished faqs

Parameters:

Code:

	<cffunction name="getUnpublishedFaqs" access="public" returntype="query" output="false" displayname="Get Unpublished Faqs" hint="I return a query of the unpublished faqs">
		<cfreturn variables.faqGateway.findUnpublished() />
	</cffunction> 

updateFaq

public void updateFaq( Event event )

I cause a faq to be updated from the current event object.

Parameters:
Event event

Code:

	<cffunction name="updateFaq" access="public" returntype="void" output="false" displayname="Update Faq" hint="I cause a faq to be updated from the current event object.">
		<cfargument name="event" type="MachII.framework.Event" required="yes" displayname="Event" hint="I am the current event" />		
		<cfset var faq = arguments.event.getArg("faq") />
		<cfset variables.faqDAO.update(faq) />	 
	</cffunction>