0

モデルのArrayCollectionがUIで更新されない問題をデバッグしています(新しいデータで表示されていても)。

そのモデルを他のコンポーネント、つまりトップレベルのコンポーネントに渡すと問題が発生するのではないかと思いました。

たとえば、トップレベルのモデルは次のとおりです。

[Bindable]
        private var meetingInfo:MeetingInfoModel;

ここで、同じクラスのコンポーネントに渡します。

<meetingViewStack:MeetingViewStack id="mainPanelContainer"
                                   newAttachmentsList="{meetingInfo.newAttachmentList}"
                                   meetingInfo="{meetingInfo}"
                                   currentState="{getPanelState(currentState)}"
                                   inCreateMeeting="false" 
                                   includeIn="runSinglePanel, runDoublePanel"
                                   height="100%"
                                   width="100%"
                                   />

そして、MeetingViewStackコンポーネントでそのプロパティを宣言する方法は次のとおりです。

[Bindable] 
        public var meetingInfo:MeetingInfoModel = MeetingInfoModel.getInstance();

MeetingViewStackでバインディングが正しく機能する必要がありますか?そのプロパティが別のコンポーネントによって渡されたとしても。

つまり、私はそれを渡す必要は本当にありません。それはモデルであり、そこで宣言することができます。

役立つヒントをありがとう!

アップデート:

MeetingInfoプロパティを更新したときに、セッターが呼び出されることを確認しました。ただし、me​​etingInfoモデルの配列コレクションを更新しても呼び出されません。

meetingInfo.docsAndAttachmentsList.sort = nameSort;
        meetingInfo.docsAndAttachmentsList.refresh();

どうすればそれを機能させることができますか?それが私が本当に探しているものです。

MeetingInfoModelクラスは次のとおりです。

package com.fmr.transporter.model

{インポートcom.fmr.transporter.events.CustomEvent; インポートcom.fmr.transporter.events.xmppServicesEvents.XMPPContactsLoadedEvent; インポートcom.fmr.transporter.services.httpservices.UserServices; インポートcom.fmr.transporter.services.xmppservices.XMPPServices; インポートcom.fmr.transporter.util.util; インポートcom.fmr.transporter.vo.ContactVO; インポートcom.fmr.transporter.vo.MeetingVO; インポートcom.fmr.transporter.vo.ParticipantVO;

import flash.events.EventDispatcher;

import mx.collections.ArrayCollection;
import mx.events.CollectionEvent;

import org.igniterealtime.xiff.data.im.RosterItemVO;

[Bindable]
public final class MeetingInfoModel extends EventDispatcher
{
    //Universal INFO
    public var generalInfo:GeneralInfoModel;
    public var meetingVO:MeetingVO = new MeetingVO();
    public var meetingId:String;

    public var bulletinBoardLiveMembers:ArrayCollection = new ArrayCollection();

    public var xmppServices:XMPPServices;

    public var declinedParticipantsGroup:ArrayCollection = new ArrayCollection();
    public var notJoinedParticipantsGroup:ArrayCollection = new ArrayCollection();
    public var conferenceRoomParticipantsGroup:ArrayCollection = new ArrayCollection();
    public var otherLocationParticipantsGroup:ArrayCollection = new ArrayCollection();

    public var documentList:ArrayCollection = new ArrayCollection();

    public var newAttachmentList:ArrayCollection = new ArrayCollection();
    public var docsAndAttachmentsList:ArrayCollection = new ArrayCollection();

    public var bulletinBoardMsgList:ArrayCollection = new ArrayCollection();

    private var _participantList:ArrayCollection = new ArrayCollection();
    public var dismissedMeetingIDs:Array = [];
    public var visibleToastWindows:Array = [];

    public function MeetingInfoModel()
    {
        generalInfo = GeneralInfoModel.getInstance();
        xmppServices = XMPPServices.getInstance();
        _participantList.addEventListener(CollectionEvent.COLLECTION_CHANGE, allParticipantsChangeHandler);
        bulletinBoardLiveMembers.addEventListener(CollectionEvent.COLLECTION_CHANGE, bulletinBoardLiveMembersChangeHandler);
    }

    private static var model:MeetingInfoModel = null;

    public static function getInstance():MeetingInfoModel
    {
        if (model == null)
        {
            model = new MeetingInfoModel();
        }
        return model;
    }

    public function displayToastForThisMeeting(meetingID:Number):Boolean
    {
        //trace("model::meetingID = " + meetingID);
        var doDisplayToast:Boolean = false;
        var containsMeetingID:Boolean = false;
        //the first one
        if(dismissedMeetingIDs.length == 0)
        {
            //trace("dismissedMeetingIDs.length = 0");
            doDisplayToast = true;
            dismissedMeetingIDs.push(meetingID);
        }
        else
        {
            for(var i:int=0; i < dismissedMeetingIDs.length; i++)
            {
                //trace("dismissedMeetingIDs[" + i + "] = " + dismissedMeetingIDs[i]);
                if(meetingID == dismissedMeetingIDs[i])
                {   //this one has already been dismissed
                    doDisplayToast = false;
                    containsMeetingID = true;
                    break;
                }
                else
                {
                    doDisplayToast = true;
                    containsMeetingID = false;
                }
            }

            if(containsMeetingID == false)
            {
                dismissedMeetingIDs.push(meetingID);
            }
        }
        return doDisplayToast;
    }

    public function setAllParticipants(value:ArrayCollection):void
    {
        _participantList = value;
        dispatchEvent(new CustomEvent(CustomEvent.HAVE_PARTICIPANT_LIST));
        calculateGroups();
    }

    public function getParticipant(loginName:String):ParticipantVO
    {   
        for each (var item:ParticipantVO in _participantList)
        {
            if (item.loginName == loginName)
            {
                return item;
            }
        }
        return null;    
    }

    private function allParticipantsChangeHandler(event:CollectionEvent):void
    {
        calculateGroups();
    }

    private function bulletinBoardLiveMembersChangeHandler(event:CollectionEvent):void
    {
        calculateGroups();
    }

    private function isInRoster( loginName:String ):Boolean { 
        for each (var newContactVO:ContactVO in model.generalInfo.allGroup)
        {
            if ( newContactVO.profileVO.email == loginName ) {
                return true;
            }
        }
        return false;
    }

    public function calculateGroups():void
    {
        var allGroup:ArrayCollection = generalInfo.allGroup;

        var participantsRosterGroup:ArrayCollection = new ArrayCollection();
        var declinedParticipantsGroup:ArrayCollection = new ArrayCollection();
        var notJoinedParticipantsGroup:ArrayCollection = new ArrayCollection();
        var conferenceRoomParticipantsGroup:ArrayCollection = new ArrayCollection();
        var otherLocationParticipantsGroup:ArrayCollection = new ArrayCollection();

        var notDeclinedParticipantsGroup:ArrayCollection = new ArrayCollection();

        for each (var item:Object in _participantList)
        {
            //because participant list contains both people and rooms, we must test to see if this is a participant
            if(item is ParticipantVO)
            {
                var xmppLoginName:String = util.formatEmailToUserName(item.loginName);
                for each (var newContactVO:ContactVO in allGroup)
                {

                    if ( item.loginName != model.generalInfo.ownerUser.loginName ) {
                        var rosterVO:RosterItemVO = newContactVO.rosterItemVO;

                        if (rosterVO.jid.node == xmppLoginName)
                        {
                            try {
                                var contactVO:ContactVO = new ContactVO();
                                //add the photo to the roster entry for each person in the meeting
                                if ( newContactVO.profileVO ) {
                                    rosterVO.photo = newContactVO.profileVO.photo;
                                    contactVO.profileVO = xmppServices.findProfile(rosterVO.jid);
                                    contactVO.profileVO = newContactVO.profileVO;
                                }
                                else {
                                    rosterVO.photo = null;
                                }

                                contactVO.rosterItemVO = rosterVO;

                            }
                            catch (e:Error) {
                                trace(e.message);
                            }

                            if (item.status == "declined")
                            {
                                declinedParticipantsGroup.addItem(contactVO);
                            }
                            else
                            {
                                notDeclinedParticipantsGroup.addItem(contactVO);
                            }
                            break;
                        }
                    }
                }
            }



        }

        for each (var contact:ContactVO in notDeclinedParticipantsGroup)
        {
            var joined:Boolean = false;
            if ( contact.rosterItemVO ) {
                for each (var memberName:String in bulletinBoardLiveMembers)
                {
                    if (contact.rosterItemVO.jid.node == memberName)
                    {
                        joined = true;

                        if (contact.rosterItemVO.jid.resource == "theconfroomimsittingin"  )
                        {
                            conferenceRoomParticipantsGroup.addItem(contact);
                        }
                        else
                        {
                            otherLocationParticipantsGroup.addItem(contact);
                        }
                        //dispatchEvent "DW has joined the meeting"
                        break;
                    }
                }
            }

            if (!joined)
            {
                notJoinedParticipantsGroup.addItem(contact);
            }
        }

        this.notJoinedParticipantsGroup = notJoinedParticipantsGroup;
        this.declinedParticipantsGroup = declinedParticipantsGroup;
        this.otherLocationParticipantsGroup = otherLocationParticipantsGroup;
        this.conferenceRoomParticipantsGroup = conferenceRoomParticipantsGroup;
    }

    public function clearMeeting():void
    {
        meetingId = "";
        _participantList.removeAll();
        docsAndAttachmentsList.removeAll();
        documentList.removeAll();
        newAttachmentList.removeAll();
        bulletinBoardMsgList.removeAll();
        bulletinBoardLiveMembers.removeAll();
    }
    [Bindable]
    public function get participantList():ArrayCollection
    {
        return _participantList;
    }

}

}

4

1 に答える 1

2

バインディングが間違っていると思います。

トップレベルでは、次のようになります。

[Bindable] private var meetingInfo:MeetingInfoModel = MeetingInfoModel.getInstance();

そして、MeetingViewStackコンポーネント内:

[Bindable] public var meetingInfo:MeetingInfoModel;

また、MeetingInfoModelクラスのどのプロパティが[Bindable]であるかによっても異なります。

于 2013-01-17T00:15:23.443 に答える