injection into views
I sincerely apologize if this question has been addressed before. I couldn't find a specific reference to anything like this in my searching.
In my main context, I have the following code:
var selectedEmployee:Employee = new Employee();
injector.mapValue(Employee, selectedEmployee, "selectedEmployee");
Then, in a view, which consists of a form I'm using, I have this in a script block:
[Inject(name="selectedEmployee")]
[Bindable]
public var selectedEmployee:Employee;
The reason for injecting into the view is so that I can easily use 2-way data binding, but I'm wondering if this is the best way. Anyhow, with Robolegs 1.0.3, this works fine. But I recently tried updating to Robotlegs 1.1.2 and this broke for some reason. The selectedEmployee object ends up being null. I'm guessing something changed and I simply need to adjust, but I'm not sure how. Am I doing something wrong here? Why would it work with 1.0.3 but not 1.1.2? I have made no other change to my code except to swap out the swc's.
Any help would be greatly appreciated.
Thanks,
Chris
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Nikos on 18 Aug, 2010 04:59 PM
What version of swiftsuspenders are you using?
Support Staff 2 Posted by Shaun Smith on 18 Aug, 2010 05:11 PM
Probably the one the comes bundled with Robotlegs v1.1.2 (SwiftSuspenders 1.5.1).
The behavior that you used to experience (injection into views that were mediated) was actually a bug with RL, and has been fixed. To regain this functionality you will need to explicitly inject dependencies into the view component. This can be done in the Mediator's onRegister() hook, like so:
Hope that helps!
3 Posted by Chris Sheffield on 18 Aug, 2010 05:24 PM
Yes! That did the trick. Thanks so much, Shaun.
Chris
4 Posted by Chris Sheffield on 18 Aug, 2010 05:34 PM
So I have to ask one more question. Is this kind of a hack or workaround to make this behavior work, or is this the proper way? Should I be going about this in some other way?
Chris
Support Staff 5 Posted by Shaun Smith on 18 Aug, 2010 07:33 PM
How does it feel to you? Does it feel hacky? I wouldn't worry too much about it to be honest. If it's working, and it doesn't make you want to tear your eyeballs out, then leave it. Later, if you decide it's hacky or high-maintenance, then look for another solution. That's my lazy answer, 'cos the real one would be too long :>
6 Posted by Chris Sheffield on 18 Aug, 2010 08:14 PM
Works for me. :-)
Thanks again.
Stray closed this discussion on 10 Feb, 2011 05:38 PM.