Spicefactory Forum Index Spicefactory
Forum Archive
 
 SearchSearch    Log inLog in 

Function binding not set after model is injected

 
Post new topic   Reply to topic    Spicefactory Forum Index -> Spicefactory
View previous topic :: View next topic  
Author Message
amarkitanis



Joined: 05 Jan 2012
Posts: 22
Location: London

PostPosted: Tue May 15, 2012 6:44 pm    Post subject: Function binding not set after model is injected Reply with quote

Hi

I have a CustomDataGrid and its columns (CustomDataGridColumn) have member variables of type Function.
So in the example, the field modifyLabelField is of type Function.

model.modifyLabelField is also a function declared in the PM.

The Parsley Context file is in the parent of the below file and declares the PM as follows:

<presentation:AssocDocPMFactory id="associatedDocumentsPM"/>

AssocDocPMFactory is a class with a sole function decorated with [Factory].

When I check inside the column (inside DataGrid's columnList) of the CustomDataGrid for this modifyLabelField, all I get is null.

Are function bindings treated differently than variables? I'm using Flex 4.5.1 together with Parsley 2.4.1

I have a feeling that model - the PM - is null until much much later and the binding does not trigger the column to set the function pointer accordingly.

I tried to use FastInject as well but to no avail.

Am I missing something?

Let me know if you need any additional info.

Code:


    <fx:Declarations>
        <spicefactory:Configure/>
    </fx:Declarations>

<fx:Script>

        [Inject(id="associatedDocumentsPM")]
        [Bindable]
        public var model:AssociatedDocumentsPM;


</fx:Script>

   <customDataGrid:CustomDataGrid id="AssocDocGrid"
                                   width="100%" height="{(documentDataList.length+2)*20}"
                                   doubleClickEnabled="true" enabled="{modeHandler.appEnable}"
                                   dataP="{documentDataList}"
                                   sortableColumns="false">
        <customDataGrid:columnList>
            <customDataGrid:CustomDataGridColumn
                textAlign="left"
                dataFieldIdentifier="documentName"
                headerText="Document Type"
                modifyLabelField="{model.modifyLabelField}"
                dataField="documentName"
                isNaNZero="true"
                showDataTips="true"
                editable="false"/>
......
</customDataGrid:columnList>




Thanks for your help!

Andreas
Back to top
View user's profile Send private message
Jens Halm
Site Admin


Joined: 21 Sep 2007
Posts: 2631
Location: Cologne, Germany

PostPosted: Tue May 15, 2012 10:59 pm    Post subject: Reply with quote

There is no way to synchronize Parsley object lifecycle with Flex component lifecycle, see chapter 8.7.5 in the manual (for version 2.4). With Configure you need to wait for [Init], with FastInject for injectionComplete (event of the tag), before that there is no way to guarantee that the PM is available.
_________________
Jens Halm
Spicefactory
Back to top
View user's profile Send private message
amarkitanis



Joined: 05 Jan 2012
Posts: 22
Location: London

PostPosted: Tue May 15, 2012 11:07 pm    Post subject: Reply with quote

I am aware of that, but I thought Flex binding generally takes care of that problem. Is that not the case for Function Binding (i.e function pointers)?
Back to top
View user's profile Send private message
Jens Halm
Site Admin


Joined: 21 Sep 2007
Posts: 2631
Location: Cologne, Germany

PostPosted: Tue May 15, 2012 11:10 pm    Post subject: Reply with quote

This must be a misunderstanding of Flex Binding. As long as the model is null, Flex Bindings cannot do magic. Once the model is non-null, the binding will fire if all parts of the chain are bindable. If that does not trigger anything, then it is a particularity of the specific property (like the one in the Column) probably not accepting to be set later, but this would be entirely a detail about Flex, not about Parsley.
_________________
Jens Halm
Spicefactory
Back to top
View user's profile Send private message
amarkitanis



Joined: 05 Jan 2012
Posts: 22
Location: London

PostPosted: Tue May 15, 2012 11:23 pm    Post subject: Reply with quote

I think it's only the case with function pointers. I will test tomorrow with a normal variable and report back!

Thanks for your input Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Spicefactory Forum Index -> Spicefactory All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group