How to get results from cfc method used as Form Action

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

  1. #1

    Default How to get results from cfc method used as Form Action

    I'm collecting a value in a form field that I want to use a parament to a cfc
    method that performs a query and then returns data for formating on the calling
    (form) page. The Form action is a cfc name with the desired method indicated
    in a hidden Input field as described in the documentation. What I can't
    figure out is how to "capture" the query results that are returned by the
    method to the calling page that contains the form.
    What happens is (even though I have output=false in the cfc and output=no in
    the method) the cfc dumps the returned data and there is no return to the
    calling form.

    All of the examples I've found have the cfc formatting the output - which is
    not recommended as best practice. Can anyone give me clue or point to some
    releavant example code? BTW i'm using MX6.1 - thanks!

    I can think of some ways to workaround this but they all seem kinda squirrely
    - maybe I'm missing some basic fact. It seems like Macromedia surely must
    have some examples of "best practices for calling a cfc from a form, have the
    cfc return data to the calling page where it is formatted for presentation"

    schep Guest

  2. Similar Questions and Discussions

    1. Problem accessing results from DataService fill method
      I've set up an application that gets data from a data service configured with a java-dao adapter. If I define a DataGrid with the array populated...
    2. CF submit form action
      hi. I have a site that uses a form for visitors to request information. when the SUBMIT button is clicked, the page returns to the home page... I...
    3. can't create action/droplet that doesn't put results on desktop
      I am ready to pull my hair out..... I am trying to create an action, and/or droplet, that will put the results in a designated folder, or even...
    4. Form action problem
      Trying to fix a web site I inherited. Problem is with the *help* page. User fills out form and hits send. The browser comes back with Error...
    5. form action
      What does "doesn't seem to work" mean? (asp.general removed from x-post list) "rOadhOg" <roadhog@nospam.phreaker.net> wrote in message...
  3. #2

    Default Re: How to get results from cfc method used as FormAction

    Hi Schep,
    Not sure about best practices, but all of a CFCs variables are available
    internally through the THIS scope. so if you have a function named "getQuery,"
    you return the values as shown in the code listing that follows.

    If you need to convert the query to a structure, you can change the returntype
    to struct and loop over the query to populate structure keys and return the
    structure to the calling page.



    <cffunction name="getQuery" returntype="query" output="false">
    <cfargument name="formArguments" required="true"/>
    <cfquery datasource="#variables.DSN#" name="qryProcForm">
    SELECT...
    </cfquery>
    <cfreturn qryProcForm>
    </cffunction>

    <!--- calling page just returns the results --->

    Hope this helps! :)

    billee Guest

  4. #3

    Default Re: How to get results from cfc method used as FormAction

    hi billee - thanks! I had missed that about being able to reference "this"
    scope from the page that invoked the component method. - I also discovered
    why I couldn't "capture" the object returned from a component method when using
    referencing components directly from the Form "Action" attribute - this reason
    is that you can't! Here's quote from docs: Clients can directly call CFC
    methods using a URL or by submitting form fields. In these cases .the CFC
    method is responsible for generating all HTML that is returned to the client

    ...thanks for getting me back on track with "this" scope!

    schep 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