di/1 issue

36 views
Skip to first unread message

Jonathan Price

unread,
Dec 21, 2014, 3:31:05 AM12/21/14
to taffy...@googlegroups.com
New to taffy, and pretty excited about how easy the basic setup was.

I'm trying to setup I pretty simple di/1 service - can you offer a suggestion on what I'm missing?

Application.cfc:

component extends="taffy.core.api" {

    this.name = "Skoroes";

    function onApplicationStart() {
        var beanFactory = new ioc("./model");
        // beanFactory.loadBeans('config/coldspring.xml');

        //set bean factory into Taffy
        variables.framework.beanFactory = beanfactory;
    }
}


playerMember.cfc:

<cfcomponent extends="taffy.core.resource" taffy:uri="/players/{playerID}">

    <cfproperty name="utilityService">

    <cffunction name="get">
        <cfargument name="playerID" />

        <cfset var local = {} />

        <cfquery name="local.qGetPlayer" datasource="skoreos_ds">
            select * from player
            where playerID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.playerID#" />
        </cfquery>

        <cfreturn representationOf( this.utilityService.QueryToArray(local.qGetPlayer )) />
    </cffunction>

</cfcomponent>

I'm seeing this in the dashboard:

   "ERROR": "Component [resources.playerMember] has no accessible Member with name [UTILITYSERVICE]",

Thanks for the help!

Jonathan Price

unread,
Dec 21, 2014, 3:32:18 AM12/21/14
to taffy...@googlegroups.com
Suppose I should've mentioned that the utility.cfc object does exist and is in the model/services directory

Jonathan Price

unread,
Dec 21, 2014, 4:26:15 AM12/21/14
to taffy...@googlegroups.com
Okay, I was suffering a few misunderstandings on my initial post, and generally, I'm unsure about some overall architectural standards here. I'm not necessarily interested in having DI/1 manage all or really any of my resources if it isn't necessary.  I think I'm just unclear on how best to proceed. 

I'm coming from some basic fw/1 experience, and I don't really understand where best to put functionality that my resources might use on the backend, like, say, some utility functions or client-specific business logic.  With fw/1, I just used services. 

Can I have resources in taffy that aren't intended to be restful?  I was under the impression that the answer to that was no, and that I needed something like di/1 to handle that.  But I think I'm off base here. 


On Sunday, December 21, 2014 12:31:05 AM UTC-8, Jonathan Price wrote:

Adam Tuttle

unread,
Dec 21, 2014, 7:14:00 AM12/21/14
to taffy...@googlegroups.com

The first issue I see in the code you sent is that you're overriding onApplicationStart but not calling super.onApplicationStart() from within your implementation. That may not solve your problems entirely, but it's a good place to start.

--
You received this message because you are subscribed to the Google Groups "Taffy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to taffy-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Puritan Paul

unread,
Jan 5, 2015, 4:13:16 PM1/5/15
to taffy...@googlegroups.com
Hi, just now getting back around to this.  I’ve got it more or less working, but with a small question.  My directory structure looks like this:

-model/
-services/
-player.cfc
-resources
-playerMember


And my playerMember file looks like this:

<cfcomponent extends="taffy.core.resource" taffy:uri="/players/{playerID}">
    <cffunction name="get">
        <cfargument name="playerID" />

        <cfset var local = {} />

        <cfset local.qGetPlayer = APPLICATION.beanFactory.getBean('playerService').getPlayer(playerID = ARGUMENTS.playerID)>

        <cfreturn representationOf( queryToArray(local.qGetPlayer) ) />
    </cffunction>
</cfcomponent>

Which works!  But, if I try this (using a property for the service, instead):

<cfcomponent extends="taffy.core.resource" taffy:uri="/players/{playerID}">
    <cfproperty name="playerService">

    <cffunction name="get">
        <cfargument name="playerID" />

        <cfset var local = {} />

 <cfset local.qGetPlayer = VARIABLES.playerService.getPlayer(playerID = ARGUMENTS.playerID)>

        <cfreturn representationOf( queryToArray(local.qGetPlayer) ) />
    </cffunction>
</cfcomponent>

I get the same ‘has no accessible Member with name [PLAYERSERVICE]’ error.  Not a huge deal, but it would be nice to not explicitly call getBean every time I need a service.  Anyone else deal with this?

I’m also all ears if my directory layout is against the grain somehow.

Thanks for the help,
Jonathan



You received this message because you are subscribed to a topic in the Google Groups "Taffy Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/taffy-users/24U4-3rryBo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to taffy-users...@googlegroups.com.

Jonathan Price

unread,
Jan 5, 2015, 7:03:56 PM1/5/15
to taffy...@googlegroups.com
BAH!  I see it in the docs now.  Works as described.  Sorry for the knuckledheadedness.  Thanks.
To unsubscribe from this group and stop receiving emails from it, send an email to taffy-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Taffy Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/taffy-users/24U4-3rryBo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to taffy-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages