Skip to main content
Inspiring
March 21, 2007
Question

Passing Flex 2 TextInput value to CFC

  • March 21, 2007
  • 6 replies
  • 500 views
If I have a Flex 2 TextInput with an id of 'querymonth' how can I pass the value entered into that to replace the hard-coded value of 'feb' in the following CFC, so I can enter the month into the TextInput before firing off the Query, and have it read the value I just entered in the CFC?

In other words, it currently says:

WHERE REPORTS.ReportDateMonth = 'feb'

But I'd like it to say, in pseudo-code

WHERE REPORTS.ReportDateMonth = 'The value I just entered into this here Flex 2 TextInput box'

<cfcomponent>
<cffunction name="getMasterQuery" output="false" access="remote" returntype="query">
<cfargument name="ID" required="false">
<cfset var qRead="">

<cfquery name="qRead" datasource="UN">
SELECT ReportType, ReportDateMonth, ReportDateYear, ReportingMember, ReportedByDueDate, ReportedDateIfLate, ReportIsNil
FROM REPORTS
WHERE REPORTS.ReportDateMonth = 'feb'
</cfquery>

<cfreturn qRead>
</cffunction>

</cfcomponent>

I need to check monthly against a total constituency and who has not reported, and after this goes into production, I won't often have easy access to go running the Query Builder in Flex/CF to change the month (not to mention, administratively, this is MUCH more convenient!). I'm sure it's simple, but I've never had to really try to use CF code yet other than a couple of things here and there...

Any help would be appreciated.

Shawn
    This topic has been closed for replies.

    6 replies

    Inspiring
    March 21, 2007
    Thanks Paul. Good to know what I'm hoping is doable. I'm sure I can figure it out by revisiting this post:) Thanks very much.

    Shawn
    Inspiring
    March 21, 2007
    shotbyshawn wrote:
    > I'm actually using the CF/Flex Wizard for all of this right now, as I'm really

    in that case find the flex bits that make the call to your CFC & change it to ad
    the text from that input field. change the CFC's arguments to what i suggested
    before.
    Inspiring
    March 21, 2007
    >>do you have your flex app setup to talk to cf? RemoteObject, method, etc setup?

    Definitely maybe...:)

    I'm actually using the CF/Flex Wizard for all of this right now, as I'm really new at this. I do see what you are both saying, pieces of it anyways, so hopefully it is something I can work out with what you wrote and searching these areas a bit more.I can definitely populate a Flex Combo Box with XML (jan, feb, mar, etc.) to co-relate with the exact field names I've used in the Access database...and unfortunately that sounds like it might be the wrong approach.

    Actually when I wrote the query, I tried to let the CF Wizard add the 'feb' only part, and it generated:

    SELECT ReportType, ReportDateMonth, ReportDateYear, ReportingMember, ReportedByDueDate, ReportedDateIfLate, ReportIsNil
    FROM REPORTS
    WHERE REPORTS.ReportDateMonth = <cfqueryparam value="#arguments.ID#" cfsqltype="CF_SQL_VARCHAR">
    AND (ReportDateMonth = 'feb')

    ...which threw me an error (too few arguments, expected 1, or something very similar), so I changed it manually to:

    WHERE REPORTS.ReportDateMonth = 'feb'

    which works fine...for feb, of course LOL.

    Shawn
    Inspiring
    March 21, 2007
    shotbyshawn wrote:
    > If I have a Flex 2 TextInput with an id of 'querymonth' how can I pass that to

    do you have your flex app setup to talk to cf? RemoteObject, method, etc setup?

    > <cfcomponent>
    > <cffunction name="getMasterQuery" output="false" access="remote"
    > returntype="query">
    > <cfargument name="ID" required="false">

    you never use this arg, so drop it & use this (guessing your month's are strings)

    <cfargument name="thisMonth" type="string" required="true">


    WHERE REPORTS.ReportDateMonth='#arguments.thisMonth#'
    Inspiring
    March 21, 2007
    Dan Bracuk wrote:
    > A couple of things. Since flex makes flash movies (swf files), you probably
    > want to convert your query to xml so flash can understand it.

    no need, flex understands cf's queries, structures, etc. in any case, it's the
    wrong way round.


    Inspiring
    March 21, 2007
    A couple of things. Since flex makes flash movies (swf files), you probably want to convert your query to xml so flash can understand it.

    Next, you have to send your text box value to the cfc method as an arguement. I'm out of my element here, so I won't say more.

    Except that using free text for month values is a bad idea. A drop down with numbers as the value and text as the display is a lot more reliable. No typos that way.