2 Replies Latest reply on Jun 27, 2007 6:22 PM by jasonpresley

    Query not being returned to Flex

    jasonpresley Level 1
      I am trying to pass a username and password to a CFC. If I hard code the values in the CFC it works like I expect but when I try to pass them I get a blank datagrid.

      <cfcomponent output="true">
      <cffunction name="readLogin" access="remote" returntype="query">
      <cfargument name="username" required="true">
      <cfargument name="password" required="true">
      <cfset var qRead="">
      <cfquery name="qRead" datasource="muller_central">
      select *
      from member
      where memUsername = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#arguments.username#" />
      and memPassword = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#arguments.password#" />
      <cfreturn qRead/>

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="initApp()">

      import mx.rpc.events.ResultEvent;
      import mx.collections.ArrayCollection;

      private var acMember:ArrayCollection;

      private function initApp():void {

      public function resultMemberLogin(event:ResultEvent):void {
      acMember = ArrayCollection(event.result);


      <mx:RemoteObject id="checkLogin" destination="ColdFusion" source="MullerIntranet.memberDAOMod" showBusyCursor="true">
      <mx:method name="readLogin" result="resultMemberLogin(event)"/>

      <mx:DataGrid dataProvider="{acMember}">

      If I change the initApp function to this:
      private function initApp():void {
      it fails because the CFC arguments username and password are set as required. However, when I pass them through the initApp function (and hard code the values into to the where statement) it works.

      Can anyone help? I am totally confused as to why I am getting a blank datagrid.

        • 1. Re: Query not being returned to Flex
          YossarianXOS Level 1
          For some reason (and it is probably ignorance on my part), I can never get RemoteObject methods to work unless I declare all of the required parameters in an <mx:arguments> tag inside the method. What I put in can be blank, though! Really kind of wierd, but we've taken to just explicitly spelling out the parameters the method takes in (which probably isn't a bad thing for maintenence anyway).

          Anyhow, try changing your method to look like this:

          <mx:method name="readLogin" result="resultMemberLogin(event)">
          • 2. Re: Query not being returned to Flex
            jasonpresley Level 1
            <cfqueryparam cfsqltype="CF_SQL_ INTEGER" value="#arguments.username#" />

            Should have been...

            <cfqueryparam cfsqltype="CF_SQL_ VARCHAR" value="#arguments.username#" />