Spicefactory Forum Index Spicefactory
Forum Archive
 
 SearchSearch    Log inLog in 

Getting Context as null

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



Joined: 30 Apr 2013
Posts: 1
Location: INDIA

PostPosted: Mon May 06, 2013 8:11 am    Post subject: Getting Context as null Reply with quote

Hi All,

We are in the phase of migrating our application based on parsley 2.3 to parsley 3.0 and we are getting context as null. I am mentioning the steps that we are following and which were working fine with 2.3 version of parsley.

1)creating the context with the help of contextbuilder tag present in mxml.Below is the screen shot of some the code lines:

<parsley:ContextBuilder>
<parsley:FlexConfig type="{AbcConfig}"/>
</parsley:ContextBuilder>

2)Fast inject context.
<parsley:FastInject property="context" type="{Context}"/>

Now when we want to access this context in other components , previously we are doing fast inject and we were able to get it but with the latest libraries of parsley that is 3.0 version , the same lines of code giving us context as null.

please suggest if we are doing something wrong while configuring context.

Also the list of libraries that we are using right now are :

parsley-core-3.0.M2.swc
parsley-flex-3.0.M2.swc
parsley-xml-3.0.M2.swc
legacy-parsley-commands-2.5.0.swc
spicelib-commands-3.1.0.swc
spicelib-reflect-3.0.0.swc
spicelib-util-3.0.0.swc

And previously we were using below mentioned library files :

spicelib-flex-2.3.0
parsley-flex4-2.3.0
_________________
Harsh~
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 07, 2013 2:21 am    Post subject: Reply with quote

Very likely a timing issue (meaning it was just pure luck it worked before your migration). I suspect you try to access the Context during events like creationComplete, which is never guaranteed to work. Instead you should use the injectionComplete event on the FastInject tag, only then the injection is guaranteed to be complete, it's simply an asynchronous operation.

For a longer explanation why other events do not reliably work, see chapter 9.7.5 in the manual for version 3.0.
_________________
Jens Halm
Spicefactory
Back to top
View user's profile Send private message
rattkin



Joined: 10 May 2011
Posts: 154
Location: Poznan, PL

PostPosted: Thu May 09, 2013 10:33 am    Post subject: Reply with quote

There are also context lookup methods, mainly in FirstChildContext and ParentContext (depending on the direction in displaylist).

If you want it in view, injectionComplete on FastInject is enough, although it might be a bit odd usage. If you have ContextBuilder in the same mxml, you can probably use complete event there (but not sure if context is fully configured by then, most probably yes). In other cases, I'd suggest using PM's and inject context there:

Code:

[Inject]
public var ctx:Context;

_________________
Sebastian Zarzycki
Feerie Software
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