At 10:44 AM 3/15/2005, you wrote:
Abdul -
That worked - thanks!
I'm still troubled as to why I can't set types for the variables in my value object, though - if anyone has an idea.
- Tom
I leave this for Matt, he is Binding guru :)
I just removed type annotation from VO
class EmployeeOptions { public var firstname; public var lastname; public var country; }
I see no error....
Stay tuned..
-abdul
-----Original Message----- From: Tom Fitzpatrick [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 15, 2005 6:58 PM To: [email protected] Subject: RE: [flexcoders] ComboBox databinding
Hi -
Your example works fine, but when I try to achieve a similar binding using a value object defined as an external class, I get a type mismatch error:
"Type mismatch in assignment statement: found Object where String is required".
Here are some more details of my test setup.
I have a value object defined as a class:
class EmployeeOptions { public var firstname:String; public var lastname:String; public var country:String; }
In a component called Employee, I've instantiated the class as:
<EmployeeOptions id="vo"/>
I'm trying to bind it from text fields and the comboBox this way:
<mx:Binding source="firstName.text" destination="vo.firstname" /> <mx:Binding source="lastName.text" destination="vo.lastname" /> <mx:Binding source="countries.value" destination="vo.country"/>
To return values to my component, I've created a delegate called EmployeeDelegate. This is instantiated in the component as:
<EmployeeDelegate id="delegate"/>
I'm trying to call methods in the delegate to populate the component with constructions such as:
<mx:Label id="Name" text="{delegate.getEmployeeName(vo.firstname,vo.lastname)}"/>
This setup works just fine with the text fields, but the comboBox gives me the type mismatch error when I use the above bindings.
Help!
- Tom
At 08:38 PM 3/14/2005, you wrote:
>Hi,
>
>I don't have the book so couldn't look at the code...I know code is
>available somewhere online, but me being lazy :)
>
>However, following code might help you...
>
>###mxBindingTest.mxml###
><mx:Application width="800" height="600"
>xmlns:mx="<<http://www.macromedia.com/2003/mxml>http://www.macromedia.com /2003/mxml>http://www.macromedia.com/20
03/mxml"
> >
>
> <!-- Form contains user input controls. -->
> <mx:Form label="Employee Information">
> <mx:FormItem label="First Name">
> <mx:TextInput id="firstName" />
> </mx:FormItem>
> <mx:FormItem label="Last Name">
> <mx:TextInput id="lastName" />
> </mx:FormItem>
> <mx:FormItem label="Department">
> <mx:TextInput id="department" />
> </mx:FormItem>
> <mx:FormItem label="Email Address">
> <mx:TextInput id="email" />
> </mx:FormItem>
> <mx:FormItem label="Country">
> <mx:ComboBox id="countries" >
> <mx:dataProvider>
> <mx:Array>
> <mx:String>India</mx:String>
> <mx:String>USA</mx:String>
> </mx:Array>
> </mx:dataProvider>
> </mx:ComboBox>
> </mx:FormItem>
> </mx:Form>
>
> <!-- The myEmployee data model -->
> <mx:Model id="myEmployee">
> <name>
> <first/>
> <last/>
> </name>
> <department/>/
> <email/>
> <country />
> </mx:Model>
>
> <!-- Properties of user interface controls are bound to the
> myEmployee data model using <mx:Binding> tags -->
>
> <mx:Binding source="firstName.text"
>destination="myEmployee.name.first" />
> <mx:Binding source="lastName.text"
>destination="myEmployee.name.last" />
> <mx:Binding source="department.text"
>destination="myEmployee.department"/>
> <mx:Binding source="email.text" destination="myEmployee.email"/>
> <mx:Binding source="countries.value"
>destination="myEmployee.country"/>
>
>
> <mx:TextInput text="{myEmployee.country}"/>
>
>
> </mx:Application>
>
>
>
>Notice how combobox box is bound to a Model and Model is bound to
>TextInput...
>
>-abdul
>
>-----Original Message-----
>From: Tom Fitzpatrick [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, March 15, 2005 6:01 AM
>To: [email protected]
>Subject: [flexcoders] ComboBox databinding
>
>
>I'm trying to create an application based on the LoanCalculator example in
>the Webster/McLeod book.
>
>Everything's working fine for simple bindings between text inputs on a form
>and the value object. Where I'm having trouble creating a databinding
>between a comboBox in the form and the value object. When the user selects
>an item in the comboBox it should be stored as a string in the value
object.
>
>What's the way to accomplish this? All the value object variables are
>public, as in the book example.
>
>Specifically, what would the <mx:Binding/> statement look like? A simple
>example would be even better.
>
>Thanks.
>
>- Tom
>
>
>
>
>
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>Yahoo! Groups Sponsor
>ADVERTISEMENT
><<http://us.ard.yahoo.com/SIG=129m8jrlh/M=298184.6018725.7038619.3001176/ D=g>http://us.ard.yahoo.com/SIG=129m8jrlh/M=298184.6018725.7038619.3001176/D=g
roups/S=1705007207:HM/EXP=1110937115/A=2593423/R=0/SIG=11el9gslf/*<http://www>http://www
.netflix.com/Default?mqso=60190075>
>click here
>
>[]
>
>
>
>----------
>Yahoo! Groups Links
> * To visit your group on the web, go to:
> *
>
<<http://groups.yahoo.com/group/flexcoders/>http://groups.yahoo.com/group/flexcoders/>http://groups.yahoo.com/group/fle
xcoders/
>
> *
> * To unsubscribe from this group, send an email to:
> *
>
<mailto:[EMAIL PROTECTED]>flexcoder
[EMAIL PROTECTED]
>
> *
> * Your use of Yahoo! Groups is subject to the
> <<http://docs.yahoo.com/info/terms/>http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service.
Yahoo! Groups Links
Yahoo! Groups Sponsor ADVERTISEMENT <http://us.ard.yahoo.com/SIG=129amadpa/M=298184.6018725.7038619.3001176/D=groups/S=1705007207:HM/EXP=1110988083/A=2593423/R=0/SIG=11el9gslf/*http://www.netflix.com/Default?mqso=60190075> click here
[]
----------
Yahoo! Groups Links
* To visit your group on the web, go to:
* <http://groups.yahoo.com/group/flexcoders/>http://groups.yahoo.com/group/flexcoders/
*
* To unsubscribe from this group, send an email to:
* <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]
*
* Your use of Yahoo! Groups is subject to the <http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service.

