tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/707-static-view-in-different-other-viewsRobotlegs: Discussion 2018-10-18T16:35:34Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/110742772011-11-03T14:59:21Z2011-11-03T14:59:40Z'static' view in different other views<div><p>Hi Andreas,</p>
<p>Let me ask a few questions, to make sure I understand what you
mean:</p>
<p>You have a view(Group), let’s call it ViewStackContainer
and it holds a ViewStack with different SubViews.<br>
Currently you are adding the “Box” to each SubView in
the stack, right?<br>
If so, I would place the “Box” in the
ViewStackContainer instead of adding and removing it to/from each
SubView.<br>
I also would have a ViewStackContainerMediator if I wanted to
influence the ViewStack's navigation from else where in my app.</p>
<p>Is the “Box” always performing the same actions, or
does it change depending on the selected View in the stack?</p>
<p>What do you think?</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/110742772011-11-03T15:18:53Z2011-11-03T15:20:43Z'static' view in different other views<div><p>Hi Ondina,</p>
<p>Thank you very much for your answer.<br>
You are correct, the "Box" is in every SubView.<br>
In my box I have a DropDownList where the user can select an item
and each subview should show the data for this item, so it is not
possible to navigate through the ViewStackContainer with this "Box"
and the action is depending on the selected View.</p>
<p>I use a template engine to genrate some more
"window"-mxml-files, so its not the easiest thing to just add
something to the ViewStackContainer, because it is in a generated
file but it is a good idea... so modifing my template file is a
first solution, if you don't have any better Ideas I will do
that.</p></div>andreastag:robotlegs.tenderapp.com,2009-10-18:Comment/110742772011-11-03T15:40:05Z2011-11-03T15:40:05Z'static' view in different other views<div><p>Andreas, you’re welcome:)</p>
<p>I posted an example of a mobile app in another thread. Sure, it
is different from a Flex ViewStack, but the idea is somehow the
same: <a href=
"http://knowledge.robotlegs.org/discussions/problems/408-mobile-viewnavigatorapplication-navigator-access#comment_11076581">
http://knowledge.robotlegs.org/discussions/problems/408-mobile-view...</a></p>
<p>Could you take a look at it?</p>
<ol>
<li>The user selects an item from a List in SomeView, which is
mediated (SomeMediator).</li>
<li>SomeView dispatches an event with the list.selectedIndex.(or
item or whatever you need) as a payload</li>
<li>SomeMediator re-dispatches it .</li>
<li>Now, this event could trigger a command or it could be listened
to by another Mediator, namely the Mediator of the
ViewStackContainer. So, the ViewStackContainerMediator would pass
the event.payload (with the list.selectedIndex) to a method in</li>
<li>ViewStackContainer, which then will change the
ViewStack.selectedIndex to the one selected in the List and also
the additional data you'd need</li>
</ol>
<p>I would place SomeView either in the ViewStackContainer or in
the parent of the ViewStackContainer, anyway just once in one
place.<br>
SomeView and ViewStackContainer communicate through their mediators
via events.<br>
Would that work for you?<br>
I hope it wasn’t too confusing.<br>
Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/110742772011-11-03T15:58:18Z2011-11-03T15:58:18Z'static' view in different other views<div><p>Or if you don’t have to change the ViewStack.selectedIndex
when the user selects an item from the List, and you just want to
show some specific data for a subview, you can dispatch the data
from SomeMediator (here just simplified, in reality you probably
would need a Model and Command too), and every SubViewMediator
would listen to it . In this case you’d have to let the
SubViews mediators decide if the incoming data is the one they
need.</p>
<p>Or you can dispatch an event with different event types for each
item in your list.<br>
Say, SomeDataEvent would have<br>
SomeDataEvent.DATA_FOR_VIEW_ONE<br>
SomeDataEvent.DATA_FOR_VIEW_TWO<br>
SomeDataEvent.DATA_FOR_VIEW_THREE as event types.<br>
And the SubViewOneMediator would listen for
SomeDataEvent.DATA_FOR_VIEW_ONE<br>
, SubViewTwoMediator would listen for
SomeDataEvent.DATA_FOR_VIEW_TWO and so on.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/110742772011-11-03T16:01:27Z2011-11-03T16:01:27Z'static' view in different other views<div><p>Hi,</p>
<p>That's exactly how my Mediator for the "Box" works, so its not
confusing at all.<br>
My problem is, however having the same object in different views,
which is not a good Idea, so I will put my "Box" in the parent
(using a little template magic so that this only happens in the
right window).</p>
<p>Thank you again for your time and for your very fast
response.</p>
<p>Andreas</p></div>andreas