Technically you don’t need to have strongly typed objects in the AS for this to work.  However it does appear that you will be going pretty deep into your object hierarchy and therefore the compiler may not know the type of objects and that it is safe for it to bind.  Your example that you’ve posted will work I think, but if you had something like {ModelLocator.userInfo.address.city} you would get a warning about unknown property address and changes won’t be detected.  Now if this data is coming from a WebService and won’t be modified you could choose to ignore the warning, but if you want to get rid of the warning you may need to do some casting: {Object(ModelLocator.userInfo.address).city}.  That will tell the compiler that it’s safe to do its thing when it comes to binding.

 

HTH,

Matt

 


From: [email protected] [mailto:[email protected]] On Behalf Of Sean McKibben
Sent: Friday, May 27, 2005 12:08 PM
To: [email protected]
Subject: [flexcoders] Data Binding and Server Objects

 

If I'm getting objects from a web service and want to use them in 
data binding, do I have to re-create them in ActionScript in order 
for their various properties and sub-objects to be bindable?

Ideally, I'd like to just "use what the server gives me" and not 
rewrite the objects in AS. i.e.:
(in my ModelLocator)
public static var userInfo:Object;

(in my GetUserCommand)
ModelLocator.userInfo = event.result[0];

(In my mxml)
<mx:Label text='{"Welcome, "+ModelLocator.userInfo.firstname+" 
"+ModelLocator.userInfo.lastname}'  />

Is it possible to get this to work like that? or will ModelLocator 
need to have something like:
public static var userInfo:UserVO;
function ModelLocator()
{
     ModelLocator.userInfo = new UserVO();
}

class com.app.path.UserVO
...


I'd rather avoid having to create all the server side objects on the 
client side; they come from the web service strongly typed, which is 
good enough for me, but does Flex need to have all of the bindable 
properties defined at complie-time for binding to work?

Thanks,
Sean




Yahoo! Groups Links

Reply via email to