+ Start a Discussion
RichardC.ax220RichardC.ax220 

Flex not resolving Salesforce connection to a component

I'm trying out the Flex toolkit using the Flex Eclipse plugin. I get the following error on my connection tag
<salesforce:Connection id="apex" />
The error says, "Could not resolve <salesforce:Connection> to a component implementation"
I have added the Salesforce Flex folder as an SWC folder.
What else do I need to do to get the connection to resolve to a component?
Ron HessRon Hess
are you able to compile the sample app ( salesforce.mxml)


you may need this
     xmlns:salesforce="com.salesforce.*"

as an attribute in your <mx:Application tag


RichardC.ax220RichardC.ax220
Ron, thanks for the reply. The Salesforce test app compiles and runs OK from Eclipse.
However, that app does not have a <salesforce:Connection /> tag, so it would not exhibit this specific problem. When I added that tag to my simple test case, the Apex plugin automatically added the Salesforce namespace to my <mx:Application> tag (nice). The code is about as simple as possible, so I included it below. All it does is try to log in to Salesforce. Let me know if you have any ideas as to what could be wrong.
Code:
<—xml version="1.0" encoding="utf-8"–>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
                xmlns:salesforce="http://www.salesforce.com/"
                applicationComplete="login();">
 <salesforce:Connection id="apex" /> <!-- This tag gets the error -->
 <mx:Script>
  <![CDATA[
   private function login():void {
      apex.login(  new LoginRequest({
          server_url : this.parameters.server_url,
          session_id : this.parameters.session_id,
          // put your own info here to test standalone
          username : '',
          password : '',
          callback : new AsyncResponder(render)
          })
      );
   }
   private function render(result:Object):void {
    headingStatus.text = "Logged in˜";
   }
  ]]>
 </mx:Script>

 <mx:Panel x="0" y="0" width="400" height="400" layout="absolute" title="">
  <mx:Label x="0" y="0" text="Simple Test Case" id="headingPrefix"/>
  <mx:Label x="175" y="0" width="200" id="headingStatus"/>
 </mx:Panel>
 
</mx:Application>

 

Ron HessRon Hess
i got this to compile, had to add two lines (import statements.)

Code:
<—xml version="1.0" encoding="utf-8"–>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
                xmlns:salesforce="http://www.salesforce.com/"
                applicationComplete="login();">
 <salesforce:Connection id="apex" /> <!-- This tag gets the error -->
 <mx:Script>
  <![CDATA[
   import com.salesforce.objects.*;
   import com.salesforce.*;
   private function login():void {
      apex.login(  new LoginRequest({
          server_url : this.parameters.server_url,
          session_id : this.parameters.session_id,
          // put your own info here to test standalone
          username : '',
          password : '',
          callback : new AsyncResponder(render)
          })
      );
   }
   private function render(result:Object):void {
    headingStatus.text = "Logged in˜";
   }
  ]]>
 </mx:Script>

 <mx:Panel x="0" y="0" width="400" height="400" layout="absolute" title="">
  <mx:Label x="0" y="0" text="Simple Test Case" id="headingPrefix"/>
  <mx:Label x="175" y="0" width="200" id="headingStatus"/>
 </mx:Panel>
 
</mx:Application>

 

the sample app does have a Connection tag, it's on line ~ 441
Code:
<salesforce:Connection id="apex"  debugEvent="echoToDebugLog(event)" sendRequest="sendRequestListener(event)"/>

 

RichardC.ax220RichardC.ax220
Hi Ron,

The import statements got it working. Thanks!