Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default CFINVOKE

    Hi,

    I've a problem invoking 2 cfc's in one function which has same return
    variable. please see the below code. my question is how does it affect if i
    return one variable for cfreturn variable. or how do i return 2 diff.variables
    for one function, is it possible.

    ================================================== =======================

    <cffunction name="test" access="remote" output="true" returnType="struct">
    <cfargument name="testFields" type="struct">

    <cfinvoke component="testOne"
    method="TestOne"
    returnVariable="ReturnValue">
    <cfinvokeargument name="tFields" value="#tFields#">
    </cfinvoke>

    <cfinvoke component="testOne"
    method="testtwo"
    returnVariable="ReturnValue">
    <cfinvokeargument name="tFields" value="#tFields#">
    </cfinvoke>

    <cfreturn ReturnValue>

    </cffunction>

    ================================================== ==============================
    =============

    appreciate if anybody could help me.
    thanks,

    weblover Guest

  2. Similar Questions and Discussions

    1. CFInvoke Tag... dumb question
      Hi, I would like to know if the CFInvoke tag is available for all versions of CF or just CFMX7? Is it supported on a default install? If not,...
    2. Using WS Stubs in CFINVOKE Tags
      Hi there, I am developing a CF family of web service components that make use of complex data types. I've noticed that CFMX generates stub Java...
    3. the saxexception on cfinvoke wsdl
      this seems to be a pretty common error and Macromedia has yet to give a consistent answer... I'm trying to use cfinvoke to use a web service, and...
    4. using cfinvoke
      Can I use <!--- file abc.cfc---> <cfcomponent> <cffunction> <cfquery> </cfquery> <cfreturn xyz> </cffunction> </cfcomponent>
    5. passing structures using cfinvoke.
      Quick question. Can I create a structure in a cfc and then return in? If so does anyone have a simple example. Thanks.
  3. #2

    Default Re: CFINVOKE

    This function will return the result from the testtwo method only, as it is called second it overwrites the ReturnValue variable set by the TestOne method.
    Stressed_Simon Guest

  4. #3

    Default Re: CFINVOKE

    To return multiple values from a function add them to a structure.
    Stressed_Simon Guest

  5. #4

    Default Re: CFINVOKE

    does it look like this. pls.advise.

    <cffunction name="test" access="remote" output="true" returnType="struct">
    <cfargument name="testFields" type="struct">

    <cfset treturnvalue = StructNew()>

    <cfinvoke component="testOne"
    method="TestOne"
    returnVariable="treturnvalue.ReturnValue(1)">
    <cfinvokeargument name="tFields" value="#tFields#">
    </cfinvoke>

    <cfinvoke component="testOne"
    method="testtwo"
    returnVariable="treturnvalue.ReturnValue(2)">
    <cfinvokeargument name="tFields" value="#tFields#">
    </cfinvoke>

    <cfreturn ReturnValue>

    </cffunction>

    weblover Guest

  6. #5

    Default Re: CFINVOKE

    I'd use one of the examples below. No need to invoke the same object twice w/i
    the same function call. Also, if you're just using numeric keys, you don't
    need a 'Struct'. Use an array.



    <!--- Option 1 --->
    <cffunction name="test" access="remote" output="true" returnType="struct">
    <cfargument name="testFields" type="struct">
    <cfscript>
    var objTest = createObject("component", "testOne");
    var treturnvalue = StructNew();
    treturnvalue[1] = objTest.testOne(arguments.tFields);;
    treturnvalue[2] = objTest.testTwo(arguments.tFields);

    return treturnvalue;
    </cfscript>
    </cffunction>

    <!--- Option 2 --->
    <cffunction name="test" access="remote" output="true" returnType="struct">
    <cfargument name="testFields" type="struct">
    <cfset var treturnvalue = StructNew()>
    <cfset var objTest = "">
    <cfobject component="testOne" name="objTest" />
    <cfset treturnvalue[1] = objTest.testOne(arguments.tFields)>
    <cfset treturnvalue[2] = objTest.testTwo(arguments.tFields)>
    <cfreturn treturnvalue>
    </cffunction>

    BSterner Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139