Here's some sample code.  I think it'll illustrate better than textual
explanation.  It's greatly abbreviated, but all the critical pieces
are there.  Note that this is totally untested code, and could well
not even compile, since I typed it directly into the webmail form
field.

user.cfc (more or less what you've got right now)
<cfcomponent displayname="user">
  <cffunction name="init" access="public" output="false" returntype="void">
    <cfargument name="dsn" type="string" required="true" />
    <cfset variables.dsn = dsn />
    <cfset variables.my.name = "" />
    <cfreturn this />
  </cffunction>
  <cffunction name="setName" access="public" output="false" returntype="void">
    <cfargument name="name" type="string" required="true" />
    <cfset variables.my.name = name />
  </cffunction>
  <cffunction name="create" access="public" output="false" returntype="void">
    <cfset var getID = "" />
    <cfquery datasource="#variables.dsn#">
      INSERT INTO user
        (name)
      VALUES
        (<cfqueryparam cfsqltype="cf_sql_varchar" value="#variables.my.name#" />
        )
    </cfquery>
    <!--- there are usually much better ways to do this --->
    <cfquery datasource="#variables.dsn#" name="getID">
      SELECT MAX(userID) AS newUserID
      FROM user
    </cfquery>
    <cfreturn getID.newUserID />
  </cffunction>
</cfcomponent>

facade.cfc
<cfcomponent displayname="facade">
  <cffunction name="init" access="remote" output="false" returntype="void">
    <cfset session.activeUser = createObject("component",
"user").init(application.config.dsn) />
  </cffunction>
  <cffunction name="setName" access="remote" output="false" returntype="void">
    <cfargument name="name" type="string" required="true" />
    <cfset session.activeUser.setName(name) />
  </cffunction>
  <cffunction name="create" access="remote" output="false" returntype="numeric">
    <cfreturn session.activeUser.create() />
  </cffunction>
</cfcomponent>

Hope that helps shed some light on the matter, and keep asking questions.

cheers,
barneyb

On Sat, 31 Jul 2004 11:06:38 -0400, Cutter (CF-Talk)
<[EMAIL PROTECTED]> wrote:
> OK, so (if I'm picking this up correctly) I can set up a CFC for my
> object (category) with some properties defined through cfproperty:
> 
> ID
> catName
> status
> 
> Then I can set up my basic 'public' or 'private' methods (does CF still
> create the get/set methods of the properties automatically, even though
> this CFC isn't a webservice?):
> 
> init([ID])
> get(ID)
> update(ID,[catName],[status])
> create([catName],[status]) [or maybe new([catName],[status])]
> delete(ID)
> list()
> 
> And then my webservice is basically a CFC for accessing my object:
> 
> getCategoryService(ID) returns type category
> setCategoryService(ID,catName,status[???]) calls category.create()
> updateCategoryService(ID,catName,status[???]) calls category.update()
> 
> Am I, somewhat, on the right track here? I can't use Flash Remoting
> because my host may not have it enabled (and even if they do it will be
> harder to get them to get it working correctly than it would be to
> design it using webservices, and I can't (currently) switch hosts).
> 
> Thanks again for everyone's assistance.
> 
> Cutter
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to