Adobe Dreamweaver Forums



Last 10 THreads :         help me with adjustments layers in CS4 (Last Post : Ann_Shelbourne@adobeforums.com - Replies : 4 - Views : 5 )           »          Re: Help authenticating installer (Last Post : Awebus - Replies : 0 - Views : 1 )           »          Site sometimes depends sessions, sometimes not,depending on user! (Last Post : VeryHopeful - Replies : 2 - Views : 3 )           »          Making a photo with rounded corners (Last Post : Linda Rathgeber - Replies : 9 - Views : 10 )           »          Problem initialising quicktime (Last Post : eoinie - Replies : 2 - Views : 3 )           »          image looks different in different browsers? (Last Post : Nancy O - Replies : 6 - Views : 7 )           »          How do I centre Tables ? (Last Post : Buringee - Replies : 2 - Views : 3 )           »          Changing Menu Bar (Last Post : Red67Coupe - Replies : 0 - Views : 1 )           »          Images not showing in IE (Last Post : Nancy O - Replies : 1 - Views : 2 )           »          Re: SFW and date created (Last Post : Ramón_G_Castañeda@adobeforums.com - Replies : 0 - Views : 1 )           »         


User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-04-2008, 09:02 AM
Imagine8
 
Posts: n/a
Diggs:
Default Passing data to components

I am only new to flex and using coldfusion and remote objects.
I have been unable to find any good information on flex and coldfusion when
trying to use components.
If anyone can point me in the right direction?
I am trying to pass data from one component to another in the main application
file.
I have a data grid in one component that when the user selects a record it
sends the primary key back to the main app file.
I then want to be able to pass that primary key in to another component or 2
that then goes and looks up related information.
The code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"
xmlns:comps="comps.*">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import events.CustomClientClass;
[Bindable]
public var clientID:String;
public function customeEvNameHandler(event:CustomClientClass):void
{
clientID = event.customClientID;
Alert.show(clientID);
}
]]>
</mx:Script>
<comps:clients id="clientView" clientIDEvt="customeEvNameHandler(event)"/>
<comps:jobs id="jobsView" showClient="{clientID}"/>
</mx:Application>

Every time I have tried to pass the data in, it passes the string client ID
not the numeric value.
The alert in the main app file is showing the correct value
The files work fine If i substitute the variable with a value.
Just unclear how if I can pass the value to the the next component.


Many thanks
Jamie



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-04-2008, 09:02 AM
atta707
 
Posts: n/a
Diggs:
Default Re: Passing data to components

Let's see if understand the problem; first of all we're talking about
comps:jobs component and the problem is clientID is being passed to it as a
String instead of a Number?

If that's right, then what's the type of property showClient on jobs
component? In you application, at least, it's typed as String.

Did I understood your question?

ATTA

Reply With Quote
  #3 (permalink)  
Old 11-04-2008, 09:02 AM
Imagine8
 
Posts: n/a
Diggs:
Default Re: Passing data to components

Hi ATTA
Thanks for the reply.
I have 2 components one is clients view, which is a data grid being populated
by remote object call to get all clients.
When a user clicks on a client in the grid it passed the primary key ie
clientID up to the main application level which I know is working and correct
with the alert I have showing the correct ID.

What I cant work out is how to pass that id to the jobs component in the main
application file so the jobs component can do its own remote object call to get
other data filtered on the client ID.
I am not sure I am even on the right track in how to pass that data in, I am
trying to populate clientID = event.customClientID;
which works via the alert but if i pass it to the <comps:jobs id="jobsView"
showClient="{clientID}"/> it is passing the literal string client ID and not
the value of client ID, if that makes sense.
I had it originally data type as an integer but if chasing the prob I tried
String.

Regards
Jamie

Reply With Quote


  #4 (permalink)  
Old 11-04-2008, 09:02 AM
atta707
 
Posts: n/a
Diggs:
Default Re: Passing data to components

is showClient property Bindable in the jobs module?

Is it just public variable or do you have get and set function for it?

Can you post some working code of this component?


Reply With Quote
  #5 (permalink)  
Old 11-04-2008, 09:02 AM
Imagine8
 
Posts: n/a
Diggs:
Default Re: Passing data to components

I really appreciate your help.
due to the nature of the client details I wont post working code at this stage.
below is the jobs component code the coldfusion function is looking for an
integer to be passed in to the jobsService.getJobsList(showClient); if I hard
code jobsService.getJobsList(1); works perfect
it is just receiving the string clientID instead of its value
CustomClientClass.as
package events
{
import flash.events.Event;

public class CustomClientClass extends Event
{
public var customClientID:String;

public function CustomClientClass(customClientID:String,type:Strin g)
{
super(type);
this.customClientID = customClientID;
}

override public function clone():Event
{
return new CustomClientClass(customClientID, type);
}
}
}
the code for jobs component.

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.core.Application;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import events.CustomClientClass;

[Bindable]
public var showClient:String;

[Bindable]
private var myJobs:ArrayCollection;

public function init():void
{
jobsService.getJobsList(showClient);
}

private function jobsResult(event:ResultEvent):void
{
myJobs = event.result as ArrayCollection;
}

private function faultHandler(event:FaultEvent):void
{
Alert.show(event.fault.faultString, event.fault.faultCode);
}
]]>
</mx:Script>

<mx:RemoteObject id="jobsService" destination="ColdFusion"
source="components.jobs.jobsGateway"
result="jobsResult(event)"
fault="faultHandler(event)"/>

<mxataGrid id="jobsDg"
dataProvider="{myJobs}"
width="400"
height="400"
dragEnabled="true">

</mxataGrid>

</mx:Panel>

Reply With Quote
  #6 (permalink)  
Old 11-04-2008, 09:02 AM
atta707
 
Posts: n/a
Diggs:
Default Re: Passing data to components

okay, let's try this:

1) change public var showClient:String to private scope and rename it to let's
just say _showClient
2) create two functions for property public function set
showClient(id:String):void and public function get showClient(): String
3) in your public function set showClinet() you'll first set the value of
private variable _showClient and then call init() method which would in turn
read the _showClient and send the request.

That should work!



Reply With Quote


  #7 (permalink)  
Old 11-04-2008, 09:02 AM
Imagine8
 
Posts: n/a
Diggs:
Default Re: Passing data to components

I have now added I have only shown the new code.
[Bindable]
private var _showClient:String;
[Bindable]
private var myJobs:ArrayCollection;
public function set showClient(value:String):void
{
_showClient= value;
}
public function get showClient():String
{
return _showClient;
}
public function init():void
{
jobsService.getJobsList(_showClient);
}
in the jobs component.

my problem still seems to lie in the way the component is called in the main
app file

<comps:jobs id="jobsView" showClient="{clientID}"/> still throws an error with
invalid data type when passing clientID to the cfc.(it is passing the literal
text cleintID still)
If i hard code like this it all works fine.
<comps:jobs id="jobsView" showClient="{2}"/>
I dont understand how to output the value of client ID not the literal string
I really appreciate your help with this.

Regards
Jamie

Reply With Quote
  #8 (permalink)  
Old 11-04-2008, 09:02 AM
atta707
 
Posts: n/a
Diggs:
Default Re: Passing data to components

there is one little detail missing, add the call to init() function in your property setter:

public function set showClient(value:String):void
{
_showClient= value;
init();
}
Reply With Quote
  #9 (permalink)  
Old 11-04-2008, 09:02 AM
Imagine8
 
Posts: n/a
Diggs:
Default Re: Passing data to components

Thanks for your help.
You are a champion
Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 12:11 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk