tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/6370-baby-steps-simple-robolegs-2-setupRobotlegs: Discussion 2013-09-26T09:38:09Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/286598452013-09-06T11:47:19Z2013-09-06T11:47:19ZBaby Steps, simple Robolegs 2 setup<div><p>Hi Jake,</p>
<p>I've modified your mini-project, see attachment.</p>
<p>1.option, using the fx declaration tag:</p>
<pre>
<code><rl:ContextBuilder>
<mvcs:MVCSBundle/>
<config:HelloWorldConfig/>
</rl:ContextBuilder></code>
</pre>
<p>2.option - actionscript:</p>
<pre>
<code>Main
private var _helloWorldContext:HelloWorldContext;
protected function preinitializeHandler(event:FlexEvent):void
{
_helloWorldContext = new HelloWorldContext(this);
}</code>
</pre>
<pre>
<code>public class HelloWorldContext
{
private var _context:IContext;
public function HelloWorldContext(view:DisplayObjectContainer)
{
_context = new Context()
.install(MVCSBundle)
.configure(HelloWorldConfig, new ContextView(view));</code>
</pre>
<ol>
<li>
<p>option - the magic happens here:<br>
<a href=
"https://github.com/robotlegs/robotlegs-framework/blob/master/src/robotlegs/bender/mxml/ContextBuilderTag.as">
https://github.com/robotlegs/robotlegs-framework/blob/master/src/ro...</a></p>
</li>
<li>
<p>option<br>
I don't have enough time right now to get into many details, so
please see a short explanation here:<br>
<a href=
"http://knowledge.robotlegs.org/discussions/robotlegs-2/4493-dispatching-context-initialization-complete-with-common-eventdispatcher#comment_28136082">
http://knowledge.robotlegs.org/discussions/robotlegs-2/4493-dispatc...</a></p>
</li>
</ol>
<p>Let me know if there is still something you don't understand and
I'll try to answer your question later on or tomorrow.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/286598452013-09-06T13:57:57Z2013-09-26T09:38:09ZBaby Steps, simple Robolegs 2 setup<div><p>The first option worked like a charm (after I replaced
"WindowedApplication" with "Application")! Got so exited, I spilled
cereal all over myself.<br>
I'll look into the other options, to further demystify the
framework.<br>
Thanks so much for your time!</p></div>Mike F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/286598452013-09-06T20:09:38Z2013-09-06T20:09:38ZBaby Steps, simple Robolegs 2 setup<div><p>(Caveat: I last updated these examples over a year ago, so they
probably need some changes to work with the final version of
RL2...)</p>
<p>Here are three examples that were originally built to teach RL1.
(I wrote<br>
two and Joel wrote one.) I later migrated all three of them to
RL2<br>
step-by-step to use as examples for a workshop session I taught at
a<br>
conference. These links point to the commit history, since that
shows the<br>
migration process and hopefully helps communicate the changes.</p>
<p>The first two are very simple apps that show a single user<br>
interaction->service->update view lifecycle. The last is a
more "real" app<br>
that Joel used in articles and workshops.</p>
<p><a href=
"https://github.com/probertson/robotlegs-examples-Simple/commits/Robotlegs2">
https://github.com/probertson/robotlegs-examples-Simple/commits/Rob...</a><br>
<a href=
"https://github.com/probertson/robotlegs-examples-Simple_NoFlex/commits/Robotlegs2">
https://github.com/probertson/robotlegs-examples-Simple_NoFlex/comm...</a><br>
<a href=
"https://github.com/probertson/robotlegs-example-ImageGalleryRL2/commits/master">
https://github.com/probertson/robotlegs-example-ImageGalleryRL2/com...</a></p>
<p>Hopefully this is helpful, and not just overwhelming :/</p>
<p>Paul</p></div>Paul Robertsontag:robotlegs.tenderapp.com,2009-10-18:Comment/286598452013-09-07T07:35:16Z2013-09-07T07:35:16ZBaby Steps, simple Robolegs 2 setup<div><blockquote>
<p>Got so exited, I spilled cereal all over myself.</p>
</blockquote>
<p>Hehe, better cereals than coffee or other liquids, for the sake
of your keyboard ;)</p>
<p>@Paul Thanks for sharing your examples with us! They are perfect
for beginners.</p>
<p>The few changes needed to make them work with the latest
rl2:</p>
<p><strong>robotlegs-examples-Simple_NoFlex-Robotlegs2</strong></p>
<p>RobotlegsSimple.as</p>
<p><strong>[1]</strong> use install instead of extend -
.install(MVCSBundle)</p>
<p><strong>[2]</strong> The Context needs a ContextView. (The
"contextView" should always be provided as the final configuration
as it may trigger context initialization.) - .configure(new
ContextView(this));</p>
<p>Instead of this:</p>
<pre>
<code>private function _initialize():void
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
_context = new Context()
.extend(MVCSBundle)
.configure(SimpleConfig, this);
addEventListener(Event.ADDED_TO_STAGE, _onApplication_AddedToStageHandler);
}</code>
</pre>
<p>use this:</p>
<pre>
<code>private function _initialize():void
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
_context = new Context()
.install(MVCSBundle)
.configure(SimpleConfig, new ContextView(this));
addEventListener(Event.ADDED_TO_STAGE, _onApplication_AddedToStageHandler);
}</code>
</pre>
<p>SimpleConfig.as</p>
<p><strong>[3]</strong> SimpleConfig should implement IConfig. (If
a config implements the IConfig interface configure() will be
invoked after construction/injection. ) That means you have access
to the Injector and the installed extensions.</p>
<p><strong>[4]</strong> The Injector has to be provided as an
interface</p>
<p><strong>[5]</strong> mediatorMap.map instead of
mediatorMap.mapView</p>
<p><strong>[6]</strong> implement IConfig.configure() method
instead of a postconstruct method</p>
<p>So, instead of this:</p>
<pre>
<code>public class SimpleConfig
{
[Inject]
public var injector:Injector
[Inject]
public var mediatorMap:IMediatorMap;
[Inject]
public var commandMap:IEventCommandMap;
[PostConstruct]
public function startup():void
{
commandMap.map(SimpleAppEvent.CHOOSE_FILE, SimpleAppEvent).toCommand(ChooseFileCommand);
commandMap.map(FileResultEvent.FILE_RESULT, FileResultEvent).toCommand(SetSelectedFileCommand);
injector.map(IFileService).toSingleton(FileService);
injector.map(SimpleModel).asSingleton();
mediatorMap.mapView(ButtonContainer).toMediator(ButtonContainerMediator);
mediatorMap.mapView(TextContainer).toMediator(TextContainerMediator);
}</code>
</pre>
<p>Use this:</p>
<pre>
<code>public class SimpleConfig implements IConfig
{
[Inject]
public var injector:IInjector;
[Inject]
public var mediatorMap:IMediatorMap;
[Inject]
public var commandMap:IEventCommandMap;
public function configure():void
{
commandMap.map(SimpleAppEvent.CHOOSE_FILE, SimpleAppEvent).toCommand(ChooseFileCommand);
commandMap.map(FileResultEvent.FILE_RESULT, FileResultEvent).toCommand(SetSelectedFileCommand);
injector.map(IFileService).toSingleton(FileService);
injector.map(SimpleModel).asSingleton();
mediatorMap.map(ButtonContainer).toMediator(ButtonContainerMediator);
mediatorMap.map(TextContainer).toMediator(TextContainerMediator);
}</code>
</pre></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/286598452013-09-07T08:31:36Z2013-09-07T08:31:36ZBaby Steps, simple Robolegs 2 setup<div><p>And here are the forked repositories with my changes:<br>
<a href=
"https://github.com/Ondina/robotlegs-examples-Simple_NoFlex">https://github.com/Ondina/robotlegs-examples-Simple_NoFlex</a><br>
<a href=
"https://github.com/Ondina/robotlegs-examples-Simple">https://github.com/Ondina/robotlegs-examples-Simple</a><br>
<a href=
"https://github.com/Ondina/robotlegs-example-ImageGalleryRL2">https://github.com/Ondina/robotlegs-example-ImageGalleryRL2</a></p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/286598452013-09-07T11:34:37Z2013-09-26T09:38:09ZBaby Steps, simple Robolegs 2 setup<div><p>@ Paul: Thanks a lot for the examples. The first ones are a
perfect starting point (seeing as I'm also only just beginning with
mxml). And I'm sure the gallery will great to get a better
understanding of services.</p>
<p>I'm going to focus on the latest version for now though.. I'm a
little paranoid that looking into the previous versions of RL will
just confuse me (more).</p>
<p>@ Ondina: Thanks again for taking the time to update the files,
and everything! You two have made my day!</p></div>Mike F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/286598452013-09-09T16:32:52Z2013-09-09T16:32:52ZBaby Steps, simple Robolegs 2 setup<div><p>Yes thanks very much Ondina for doing the updates for me! If you
haven't<br>
already, feel free to submit pull requests and I'll integrate
them.</p>
<p>Paul</p>
<p>On Saturday, September 7, 2013, Jake wrote:</p></div>Paul Robertsontag:robotlegs.tenderapp.com,2009-10-18:Comment/286598452013-09-09T16:52:21Z2013-09-09T16:52:21ZBaby Steps, simple Robolegs 2 setup<div><blockquote>
<p>If you haven't already, feel free to submit pull requests and
I'll integrate them.</p>
</blockquote>
<p>@Paul - Done:)</p>
<p>@Jake - Glad we could help!</p>
<p>I'm going to close this thread, but feel free to re-open it, if
need be, and, of course, you can open new ones for other
issues/questions.</p>
<p>Ondina</p></div>Ondina D.F.