Thanks to all who have been assisting here. After reading all of the various replies, as well as a lot of time reading over two tons of articles, I appear to be (slowly) making some progress.

Currently I am using a CategoryServices.cfc to access the category object created by my category.cfc. I am able to initialize the object using the following init() method:

<cffunction name="getCategory" access="remote" returnType="struct" output="false">
<cfargument name="ID" type="numeric">

<cfscript>
variables.returnStruct = StructNew();
variables.returnStruct.ID = 0;
variables.returnStruct.catName = "";
variables.returnStruct.status = 1;

if (arguments.ID neq 0)
session.newCat = CreateObject('component','category5').init(arguments.ID);
else
session.newCat = CreateObject('component','category5').init();

variables.returnStruct.ID = session.newCat.getID();
variables.returnStruct.catName = session.newCat.getCategoryName();
variables.returnStruct.status = session.newCat.getStatus();
</cfscript>

<cfreturn variables.returnStruct>
</cffunction>


I thought that be instantiating the object within a session variable that it would perpetuate for further method calls along these lines:

<cffunction name="deleteCat" access="remote" returntype="void" output="false">
<cfargument name="ID" type="numeric">

<cfif arguments.ID neq 0>
<cfset session.newCat.delete(arguments.ID)>
</cfif>
</cffunction>

<cffunction name="setCatName" access="remote" returntype="void" output="false">
<cfargument name="catName" type="string">
<cfset session.newCat.setCategoryName("#arguments.catName#")>
</cffunction>

<cffunction name="setCatStatus" access="remote" returntype="void" output="false">
<cfargument name="status" type="boolean">
<cfset session.newCat.setStatus(arguments.status)>
</cffunction>

<cffunction name="createCat" access="remote" returntype="numeric" output="false">
<cfscript>
session.newCat.create();
returnID = session.newCat.getID();
</cfscript>
<cfreturn returnID>
</cffunction>


But what I find is, though I can initialize through the webservice:

<cfinvoke
 webservice="http://[mypath]/boutique/CategoryServices.cfc?wsdl";
 method="init"
 returnvariable="aCat">
        <cfinvokeargument name="ID" value="1">
</cfinvoke>


<cfdump expand="yes" var="#aCat#"><br />

The session variable apparently does not persist. The next line of code:

<cfdump expand="yes" var="#session.newCat#">

gives the following error:

Error Occurred While Processing Request
Element NEWCAT is undefined in SESSION.


The error occurred in [mypath]\testing.cfm: line 18

16 :
17 : <cfdump expand="yes" var="#aCat#"><br />
18 : <cfdump expand="yes" var="#session.newCat#">


Is the session variable created here not persistent? Is it automatically "cleaned" once a method has been completed?


Cutter


Barney Boisvert wrote:

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]

----------------------------------------------------------
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