Hi Matt,

I create the example that shows the bug, in case I was not missing something.

The example uses an ArrayCollection to fire a property variable and then bind this variable to the TextInput. In my Application the AC is in a ModelLocator, and I expect that changes in the AC will be reflected in the textinput with a little processing that turns the list into a string separated by ";".

In my real case Application I get the ArrayCollection populated with a server service, and the textinput shows the composed string as expected, then I try to remove all items, or create a new AC(), and nothig happens.

Here is the example I prepare:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml "
        layout="vertical" creationComplete="initApp()">
       
        <mx:TextInput id="stringResult" text="{sessionUsersToString}"/>
       
        <mx:Button label="remove all items" click="removeAll()"/>
       
        <mx:Binding source="sessionUsers" destination="sessionUsersToString"/>
        <mx:Script>
                <![CDATA[
                    import mx.collections.IViewCursor ;
                    import mx.collections.ArrayCollection;
                   
                    [Bindable]
                    public var sessionUsers:ArrayCollection;
                   
                    public function initApp():void {
                        sessionUsers = new ArrayCollection([
                            {user:"Juan", id:10},
                            {user:"Carlos", id:20},
                            {user:"Lucas", id:30}
                        ]);
                    }
                   
                    // --- sessionUsersToString
                    private var _sessionUsersToString:String;
                    [Bindable]
                    public function get sessionUsersToString():String {
                        var users:String = "";
                        var iterator:IViewCursor = sessionUsers.createCursor();
                       
                        while(!iterator.afterLast) {
                            if(users != "")
                                users += ";";
                            users += iterator.current.user;
                            iterator.moveNext();
                        }
                                       
                        return users;   
                    }
                    public function set sessionUsersToString(value:String):void {
                        _sessionUsersToString = value;
                    }
                   
                    public function removeAll():void {
                        sessionUsers.removeAll();
                       
                        // --- Here I tried several methods
                        // *BindingUtils.bindProperty
                        // *sessionUsers = new ArrayCollection();
                        // ...
                    }
                ]]>
        </mx:Script>
       
</mx:Application>

Hope someone could throw some light into this issue.

Thanks.

C.



On 8/7/06, Matt Chotin <[EMAIL PROTECTED]> wrote:

If you are bound to the ArrayCollection then manipulating the AC itself doesn't re-trigger the binding.  You need to do a re-assignment.  If that isn't working make sure that the variable for your AC is [Bindable] and if you wrote a setter and used [Bindable(event="…")] that you actually dispatched the event.

 


From: [EMAIL PROTECTED] ups.com [mailto:[EMAIL PROTECTED] ups.com] On Behalf Of Carlos Rovira
Sent: Sunday, August 06, 2006 10:25 AM
To: [EMAIL PROTECTED]ups.com
Subject: [flexcoders] [Flex 2][ArrayCollection][Bug] Bindings don't executing when setting AC to a new ArrayCollection()

 

Hi,

I'm experiencing a bug with an ArrayCollection. I want to remove the contents and the new state should dispatch a Binding, but this is not happen at all.

I was trying several methods:

* setting to null;
* new ArrayCollection();
* calling removeAll()
* calligin refresh() as well

but nothing happens.

I suppose that this should be a known issue, anyone knows some trick to avoid this problem?

Thanks.

--
::| Carlos Rovira
::| http://www.carlosrovira.com




--
::| Carlos Rovira
::| http://www.carlosrovira.com __._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to