Hi...very much a Mach-II newbie, though I've been a ColdFusion
developer for almost 10 years. My coworker and I learned about Mach-II
at CFUnited 09, and we decided that this is the framework we wanted to
implement in our developer's group. We're going from having used no
framework at all or any expose to them (we are a wee bit behind).
(Side note: thanks for the great presentations Kurt!)

With that background, I went through the tutorial in the documentation
fairly well, so I decided my first Mach-II project would be a fairly
simple, small app to help me really get the concepts and methology
down. So using the tutorial, I've gotten the home page working
beautifully. Did my views, along with my first gateway and listener.
On this home page, there is a list of categories. You click on one and
it takes you to a page that lists the fact sheets in that category. At
the top, I'm including a header with the name of the category and its
range number.

I'm working on that part now, but I keep getting an error. I've looked
at all of my code, comparing it to the tutorial code since they both
have category pages, and I just can not see where I'm messing up.
After two days of reading and rereading, I'm not sure what else to
try. I'm using Mach-II 1.6.0 and we're running ColdFusion 8 Enterprise
on RedHat Linux.  Thanks in advance if anyone can help spot my
mistake. Details of the files below.

Message: The value returned from the getCategoryDetail function is not
of type category.

Detail: If the component name is specified as a return type, its
possible that a definition file for the component cannot be found or
is not accessible.

Tag Context:
/var/www/html/frameworks/MachII/framework/invokers/EventInvoker.cfc
(67)
/var/www/html/frameworks/MachII/framework/commands/NotifyCommand.cfc
(68)
/var/www/html/frameworks/MachII/framework/EventHandler.cfc (62)
/var/www/html/frameworks/MachII/framework/RequestHandler.cfc (328)
/var/www/html/frameworks/MachII/framework/RequestHandler.cfc (276)
/var/www/html/frameworks/MachII/framework/RequestHandler.cfc (217)
/var/www/html/frameworks/MachII/framework/RequestHandler.cfc (147)
/var/www/html/frameworks/MachII/mach-ii.cfc (153)
/var/www/html/frameworks/MachII/mach-ii.cfc (75)

This is the event handler from my mach-ii.xml
<event-handler event="showCategoryDetails" access="public">
    <notify listener="categoriesListener" method="getCategoryDetail"
resultArg="CategoryBean" />
    <notify listener="categoriesListener" method="getSheetsInCat"
resultArg="qCategories" />
    <view-page name="header" />
    <view-page name="categorydisplay" />
    <view-page name="footer" />
</event-handler>

This is the listener CategoryListener.cfc
<cfcomponent name="CategoryListener" displayname="CategoryListener"
output="false" extends="MachII.framework.Listener">
    <!--- Configures this listener as part of the Mach-II framework ---
>
    <cffunction name="configure" access="public" output="false"
returntype="void">
        <!--- do nothing for now --->
    </cffunction>

    <!--- returns the query recordset returned by the Category Gateway
--->
    <cffunction name="getCategoryList" access="public" output="false"
returntype="query">
        <cfset var categoriesGateway = createObject("component",
"model.categoriesGateway").init( DSN = request.DSN ) />
        <cfreturn categoriesGateway.getAllCategories() />
    </cffunction>

    <!--- Gets detail on a single Category --->
    <cffunction name="getCategoryDetail" access="public"
output="false" returntype="category">
        <cfargument name="event" type="MachII.framework.Event"
required="true" />

        <cfset var category = createObject("component",
"model.category").init( arguments.event.getArg("whichcategory") ) />
        <cfset var categoryDAO = createObject("component",
"model.categoryDAO").init( DSN = request.DSN ) />

        <cfset categoryDAO.read(Category) />

        <cfreturn category />
    </cffunction>
</cfcomponent>

This is the DAO - CategoryDAO.cfc
<!--- DAO (Data Access Object) for Categories --->
<cfcomponent name="categoryDAO" output="false">
    <cffunction name="init" access="public" output="false"
returntype="categoryDAO">
        <cfargument name="DSN" type="string" required="true"
hint="datasource" />
        <cfset variables.DSN = arguments.DSN />
        <cfreturn this />
    </cffunction>

    <!--- Returns our populated Category bean! --->
    <cffunction name="read" access="public" output="false"
returntype="category">
        <!--- the bean to populate? --->
        <cfargument name="Category" type="category" required="true" />

        <cfset var queryCategories = "" />

        <!--- Make sure Category requested is a valid number --->
        <cfif val(arguments.Category.getCategoryID()) GT 0>
            <!--- run the query based on the ID loaded from the
Listener function --->
            <cfquery name="queryCategories"
datasource="#variables.DSN#">
                SELECT categoryid, categoryname, description, range
                FROM categories
                WHERE categoryid = <cfqueryparam
value="#arguments.Category.getCategoryID()#"
cfsqltype="cf_sql_integer" />
            </cfquery>

            <!--- re-initialize the bean with data from the query --->
            <cfset arguments.Category.init( CategoryID =
queryCategories.categoryid,
                CategoryName = queryCategories.categoryname,
                Description = queryCategories.description,
                Range = queryCategories.range ) />

        </cfif>
        <!--- Return the populated bean --->
        <cfreturn arguments.Category />
    </cffunction>
</cfcomponent>

And here is the bean - Category.cfc
<!--- This is our Category bean! --->
<cfcomponent name="category">
    <cfset variables.instance.CategoryID = 0 />
    <cfset variables.instance.CategoryName = "" />
    <cfset variables.instance.Description = "" />
    <cfset variables.instance.Range = "" />

    <!--- initialize our bean --->
    <cffunction name="init" displayname="init" access="public"
output="false" returntype="category">
        <cfargument name="CategoryID" type="numeric" required="false"
default="0" />
        <cfargument name="CategoryName" type="string" required="false"
default="" />
        <cfargument name="Description" type="string" required="false"
default="" />
        <cfargument name="Range" type="string" required="false"
default="" />

        <cfset setCategoryID(arguments.CategoryID) />
        <cfset setCategoryName(arguments.CategoryName) />
        <cfset setDescription(arguments.Description) />
        <cfset setRange(arguments.Range) />

        <cfreturn this />
    </cffunction>

    <!--- all of our getters and setters for said bean --->
    <cffunction name="getCategoryID" access="public" output="false"
returnType="numeric">
        <cfreturn variables.instance.CategoryID />
    </cffunction>
    <cffunction name="setCategoryID" access="private" output="false"
returnType="void">
        <cfargument name="CategoryID" required="yes" type="numeric" />
        <cfset variables.instance.CategoryID = arguments.CategoryID />
    </cffunction>

    <cffunction name="getCategoryName" access="public" output="false"
returnType="string">
        <cfreturn variables.instance.Name />
    </cffunction>
    <cffunction name="setCategoryName" access="private" output="false"
returnType="void">
        <cfargument name="CategoryName" required="yes" type="string" /
>
        <cfset variables.instance.CategoryName =
arguments.CategoryName />
    </cffunction>

    <cffunction name="getDescription" access="public" output="false"
returnType="string">
        <cfreturn variables.instance.Description />
    </cffunction>
    <cffunction name="setDescription" access="private" output="false"
returnType="void">
        <cfargument name="Description" required="yes" type="string" />
        <cfset variables.instance.Description = arguments.Description /
>
    </cffunction>

    <cffunction name="getRange" access="public" output="false"
returnType="string">
        <cfreturn variables.instance.Range />
    </cffunction>
    <cffunction name="setRange" access="private" output="false"
returnType="void">
        <cfargument name="Range" required="yes" type="string" />
        <cfset variables.instance.Range = arguments.Range />
    </cffunction>
</cfcomponent>



Summer S. Wilson
Software Engineer II
AgriLife Information Technology
979-458-1458 (p) / 979-845-0829 (f)
2468 TAMU; 110 TAES Annex Building

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to Mach-II for CFML list.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/mach-ii-for-coldfusion?hl=en
SVN: http://greatbiztoolsllc.svn.cvsdude.com/mach-ii/
Wiki / Documentation / Tickets: 
http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/
-~----------~----~----~----~------~----~------~--~---

Reply via email to