SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    ********* Articles ArticleBot's Avatar
    Join Date
    Apr 2001
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Article Discussion

    This is an article discussion thread for discussing the SitePoint article, "ColdFusion Components - An Introduction"

  2. #2
    Nate
    SitePoint Community Guest
    Just letting you know you have a syntax error in the example. [component="compontents.users.general.users"] Should obviously read [component="components.users.general.users"]
    (spelled components as compontents)

    take care.

  3. #3
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Ivanhoe
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do you return errors from CFCs???

    I am wondering how to return an error message from a CFC function which has a return type of QUERY. If I want to return a database error how do I do it? The function will want to return a query not a message string.

    I have tried to write a generic return routine that handles messages as well as data. I have put that routine in a base component and all other components extend that base component. Unfortunately I can't get it to work. It keeps telling me the object I have assigned the CFC to is undefined.

    I'd love to know how you have written this into your CFCs.

    Many thanks,

    Lazz.

  4. #4
    Non-Member
    Join Date
    Oct 2005
    Location
    INDIA
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lots of thanx 2 ERIC
    It was relly helpful for me.thanx for the cute tutorial

  5. #5
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lazz...

    You could change the return type of your CFC from query, to structure, then add in any error messages too, maybe like this:

    <cfset returnStruct = StructNew()>
    <cfset returntype.query = myQueryName>
    <cfset returntype.error = myErrorMessage>

    <cfreturn returnStruct>
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  6. #6
    minister of propaganda silver trophy Rynoguill's Avatar
    Join Date
    Feb 2004
    Location
    Midsouth
    Posts
    1,373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Lazz
    I am wondering how to return an error message from a CFC function which has a return type of QUERY. If I want to return a database error how do I do it? The function will want to return a query not a message string.

    I have tried to write a generic return routine that handles messages as well as data. I have put that routine in a base component and all other components extend that base component. Unfortunately I can't get it to work. It keeps telling me the object I have assigned the CFC to is undefined.

    I'd love to know how you have written this into your CFCs.

    Many thanks,

    Lazz.
    Check out <cftry> and <cfcatch> and <cfthrow>. I can get you documentation pages if you need them. but just check out livedocs.macromedia.com.
    rynoguill
    Ryan Guill, AKA Mark Roman

  7. #7
    minister of propaganda silver trophy Rynoguill's Avatar
    Join Date
    Feb 2004
    Location
    Midsouth
    Posts
    1,373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by creole
    Lazz...

    You could change the return type of your CFC from query, to structure, then add in any error messages too, maybe like this:

    <cfset returnStruct = StructNew()>
    <cfset returntype.query = myQueryName>
    <cfset returntype.error = myErrorMessage>

    <cfreturn returnStruct>
    Ive done this sort of thing before too, and it works well as long as you are ready to handle it on the receiving end. The cfthrow will just do a terminating error.
    rynoguill
    Ryan Guill, AKA Mark Roman

  8. #8
    sabiha chowdhury
    SitePoint Community Guest
    what is the advantage using CFC rather than normal coding in one cfm page

  9. #9
    SitePoint Addict dek's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sabiha chowdhury
    what is the advantage using CFC rather than normal coding in one cfm page
    I thought the reasons given in the article were pretty compelling myself...
    Only dead fish go with the flow

  10. #10
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Rynoguill
    Ive done this sort of thing before too, and it works well as long as you are ready to handle it on the receiving end. The cfthrow will just do a terminating error.
    But isn't that "outputting from a CFC?" GASP!!!
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  11. #11
    shariff
    SitePoint Community Guest
    thanks a very good tutorial about components in coldfusion


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •