tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/817-using-a-callout-with-a-listRobotlegs: Discussion 2012-02-14T18:19:25Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/135802052012-02-10T11:43:08Z2012-02-10T12:38:41Zusing a callout with a list<div><p>Hi Corey,</p>
<p>A Callout container is like a pop-up TitleWindow container.<br>
You need to manually create a Mediator for the callout:<br>
<a href=
"http://knowledge.robotlegs.org/kb/reference-mvcs-implementation/how-to-mediate-a-flex-popup">
http://knowledge.robotlegs.org/kb/reference-mvcs-implementation/how...</a></p>
<p>Have you tried that already and it didn’t work?</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/135802052012-02-10T16:59:48Z2012-02-10T17:07:00Zusing a callout with a list<div><p>Take a look at:</p>
<p><a href=
"https://github.com/Ondina/robotlegs-incremental/blob/master/robotlegsincremental/robotlegs-mobile-tabbed/src/com/robotlegs/demos/robotlegsincremental/controllers/commands/mappings/MapViewsCommand.as">
MapViewsCommand</a></p>
<p><a href=
"https://github.com/Ondina/robotlegs-incremental/blob/master/robotlegsincremental/robotlegs-mobile-tabbed/src/com/robotlegs/demos/robotlegsincremental/controllers/commands/popup/OpenPopUpCommand.as">
OpenPopUpCommand</a> : it creates the needed mediators (for
SomeCallOutView and ListView)</p>
<p><a href=
"https://github.com/Ondina/robotlegs-incremental/tree/master/robotlegsincremental/robotlegs-mobile-tabbed/src/com/robotlegs/demos/robotlegsincremental/views/components">
Views</a>: SomeView, SomeCallOutView, and ListView</p>
<p>and their <a href=
"https://github.com/Ondina/robotlegs-incremental/tree/master/robotlegsincremental/robotlegs-mobile-tabbed/src/com/robotlegs/demos/robotlegsincremental/views/mediators">
Mediators</a> : SomeMediator, SomeCallOutMediator, ListMediator</p>
<p>I hope that's helpful. Let me know if you need more info.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/135802052012-02-13T08:39:00Z2012-02-13T08:39:00Zusing a callout with a list<div><p>I have followed your suggestion, however mine differs slightly
in that I can't use the addelement to pop the object on the
stage.</p>
<p>I am now able to narrow down the problem. The filterview is not
being mediated. Even though I am explicitly mediating it here in a
command.</p>
<pre>
override public function execute():void{
var filtercallout:FilterListlayout = new FilterListlayout();
var filterview:FilterView = new FilterView();
filtercallout.selectedItems = event.data;
//var listView:ListView = new ListView();
this.mediatorMap.createMediator(filtercallout);
this.mediatorMap.createMediator(filterview);
filtercallout.open(event.owner as DisplayObjectContainer, true);
}
</pre>
<p>Essentially my callout contains a viewnavigator which in turn
contains the filterview as the first view.</p>
<p>`<s:ViewNavigator creationComplete="init()" id="viewNav"
width="100%" height="100%"</p>
<pre>
<code>firstView="com.lmc.remoteadmin.view.FilterView">
<s:navigationContent>
<s:Button label="Cancel" click="close(false)"/>
</s:navigationContent>
<s:actionContent>
<s:Button id="done" label="OK" emphasized="true" click="done_clickHandler(event);" />
</s:actionContent>
</s:ViewNavigator></code>
</pre>
<p>`</p></div>coreytag:robotlegs.tenderapp.com,2009-10-18:Comment/135802052012-02-13T13:15:19Z2012-02-13T13:21:02Zusing a callout with a list<div><p>That’s a bit tricky and it won’t work in the
command, because you’d need ViewNavigator’s activeView
for the mapping, and by the time the command creates the mediator
for ViewNavigator, its activeView is still null.<br>
A possible solution would be to map the View(your FilterView)
contained in the ViewNavigator within ViewNavigator’s
Mediator onRegister(), after the View(FilterView ) has been added
to ViewNavigator’s display list. Not a very nice solution,
but the only one I can come up with right now. I wonder if there is
another(better) solution.</p>
<p>Using my example, SomeCallOutView would add a CalloutNavigator,
which is a ViewNavigator with a firstView set to AnotherView.<br>
So you’d need a CalloutNavigatorMediator, which will create
AnotherMediator for AnotherView.</p>
<ul>
<li>
<p>In the command: var someCallOut:SomeCallOutView = new
SomeCallOutView();//a Callout container<br>
var calloutNavigator:CalloutNavigator = new CalloutNavigator();//a
ViewNavigator<br>
mediatorMap.createMediator(someCallOut);<br>
someCallOut.open(event.popUpOwner, true);<br>
someCallOut.calloutGroup.addElement(calloutNavigator);<br>
tmediatorMap.createMediator(calloutNavigator);</p>
</li>
<li>
<p>CalloutNavigator.mxml (ViewNavigator)
firstView="com.robotlegs.demos.robotlegsincremental.views.components.AnotherView"</p>
</li>
<li>
<p>AnotherView.mxml // spark.components.View containing a list</p>
</li>
<li>
<p>CalloutNavigatorMediator [Inject] public var
view:CalloutNavigator;<br>
onRegister():<br>
mediatorMap.createMediator(<strong>view.activeView</strong>);<br>
//active view= AnotherView</p>
</li>
</ul>
<p>I tried it out and it works. Tell me how it goes, and of course,
if you find a better solution, please share it with us :)</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/135802052012-02-13T19:33:50Z2012-02-13T19:33:50Zusing a callout with a list<div><p>I did finally get it to work with a few exceptions:</p>
<ol>
<li>the callout.open command needs to be called last otherwise the
popup doesn't size the window properly after adding the
element.</li>
</ol>
<pre>
public class FilterListOpenCommand extends Command
{
[Inject] public var event:FilterListLayoutEvent;
public function FilterListOpenCommand()
{
super();
}
override public function execute():void{
var filtercallout:FilterListlayout = new FilterListlayout();
var calloutnavigator:ListCalloutViewNavigator = new ListCalloutViewNavigator();
filtercallout.addElement(calloutnavigator);
this.mediatorMap.createMediator(calloutnavigator);
this.mediatorMap.createMediator(filtercallout);
filtercallout.open(event.owner as DisplayObjectContainer, true);
}
}
</pre>
<ol>
<li>I am having trouble closing my callout. Below is my code to
close it but I keep getting the following error<br>
<code>Injector is missing a rule to handle injection into property
"view"</code></li>
</ol>
<pre>
public class FilterListCloseCommand extends Command
{
[Inject] public var event:FilterListLayoutEvent;
[Inject] public var view:FilterListlayout;
[Inject] public var viewnav:ListCalloutViewNavigator;
public function FilterListCloseCommand()
{
super();
}
override public function execute():void{
this.mediatorMap.removeMediatorByView(view);
this.mediatorMap.removeMediatorByView(viewnav);
view.close();
// inform the user of the selected items
dispatch(new FilterListLayoutEvent(FilterListLayoutEvent.CHANGE, event.data));
}
}
</pre></div>coreytag:robotlegs.tenderapp.com,2009-10-18:Comment/135802052012-02-14T09:54:32Z2012-02-14T09:54:32Zusing a callout with a list<div><p>You can do this:</p>
<p>Opening command:<br>
var someCallOutView:SomeCallOutView
=injector.instantiate(SomeCallOutView);<br>
var calloutNavigator:CalloutNavigator =
injector.instantiate(CalloutNavigator);<br>
injector.mapValue( CalloutNavigator, calloutNavigator );<br>
injector.mapValue( SomeCallOutView, someCallOutView );</p>
<p>mediatorMap.createMediator(someCallOutView);<br>
someCallOutView.open(event.popUpOwner, true);<br>
someCallOutView.calloutGroup.addElement(calloutNavigator);<br>
mediatorMap.createMediator(calloutNavigator);</p>
<p>Closing command:<br>
var calloutNavigator:CalloutNavigator =
injector.getInstance(CalloutNavigator);<br>
var someCallOutView:SomeCallOutView =
injector.getInstance(SomeCallOutView);<br>
mediatorMap.removeMediatorByView(someCallOutView);<br>
mediatorMap.removeMediatorByView(calloutNavigator);</p>
<p>(no need to inject the views)</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/135802052012-02-14T09:59:24Z2012-02-14T09:59:24Zusing a callout with a list<div><p>On the other hand you can let each interested Mediator listen
for the SomePopUpEvent.CLOSE_POPUP event dispatched by the view and
perform mediatorMap.removeMediator(this); instead of using a
command.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/135802052012-02-14T18:06:50Z2012-02-14T18:06:50Zusing a callout with a list<div><p>Thank ou so much for the help. I probably use the mediator
method but its nice to know the command method as well.</p></div>corey