Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

I am in Middle of CFC

Participant ,
Dec 15, 2008 Dec 15, 2008
I implement my ajax Delete functionality and it works fine within a grid.

it delete the records.

But i have a image related to the delete functionality. whenever i run that function my image do not get deleted.

how can i change the code to make it work:

here is my code:

function deleteTheme() {
var proxyp = new DeleteThe();
proxyp.setErrorHandler(errorHandler);
proxyp.setCallbackHandler(DeleteCallback);

var dID = ColdFusion.getElementValue('Grid01','Form1','ID');
proxyp.DeleteThe(dID);
<cfajaxproxy cfc="cfc.cfc1" jsclassname="DeleteThe">

this code runs the cfc function which delete the joke.

i tried adding the functionality like in a cfc in different function

<cfif fileexists('imagefile')>
<cffile action=delete" file="path">
</cfif>

but it did not worked out
TOPICS
Getting started
757
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 15, 2008 Dec 15, 2008
you will need to code the delete file process into your DeleteThe
function in your cfc.
you are passing some id to your function -> query the db to get the
filename associated with that id -> delete the file if it exists ->
delete the record from your db

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 15, 2008 Dec 15, 2008
I am using ID of theme table to delete the file, how do i point to the file so i can write in the detail in cfc:

i thought of a n example as:

<cffunction access="remote" name="DeleteListedTheme" verifyclient="yes" returntype="void" output="no">
<cfargument name="themeID" required="yes" default="" type="numeric">
<cfset mydel = "">
<cfquery datasource="#request.dsn#" username="#request.user#" password="#request.pass#" name="mydel">
DELETE FROM
themes
WHERE
themeID = <cfqueryparam cfsqltype="cf_sql_numeric" value="#trim(arguments.themeID)#">
</cfquery>
<cfif filexists(where should i find the file based of ID)>
<cffile action=delete file="path to file">
</cfif>
</cffunction>

but it not working
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 15, 2008 Dec 15, 2008
<cffunction ...>
<cfargument ...>
<cfset VAR mydel = "">
<cfset VAR myq = "">
<cfset VAR imagepath = "path/to/where/you/store/the/images/">
<cfquery name="myq" ...>
SELECT imagefilenamecolumn
FROM themes
WHERE themeID = <cfqueryparam cfsqltype="cf_sql_numeric"
value="#trim(arguments.themeID)#">
</cfquery>
<cfif fileexists(imagepathe & myq.imagefilenamecolumn)>
<cffile action="delete" file="#imagepath & myq.imagefilenamecolumn#">
</cfif>
<cfquery name="mydel" ...>
...
</cfquery>
</cffunction>

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 16, 2008 Dec 16, 2008
Thanks AZADI..

Well one new thing i learned the two queries you used in a single cffuntion tags.

well any number of queries can be used in one cffuntion

Yes/No

Thanks
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 16, 2008 Dec 16, 2008
LATEST
yes. you can use any number of queries in a single function.
you can also call other functions from same or other components.
so if you already have another function in this or other component that
returns the image filename based on theme id you can just call that
function instead of writing another query:

<cffunction name="getImageFilename" ...>
<cfargument name="themeID" ...>
<cfset var qFilename = "">
<cfquery name="qFilename" ...>
SELECT imagefilenamecolumn
FROM ...
WHERE themeid = ...
</cfquery>
<cfreturn qFilename.imagefilenamecolumn>
</cffunction>

<cffunction name="deleteTheme" ...>
<cfargument name="themeID" ...>
<cfset var imagefile = getImageFilename(arguments.themeID)>
<cfset var qDelete = "">
<cfset var imagepath = "...">
<cfif fileexists(imagepath & imagefile)>
<cffile action="delete" ...>
</cfif>
<cfquery name="qDelete" ...>
DELETE FROM themes WHERE ...
</cfquery>
</cffunction>


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources