tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/2711-how-to-properly-update-datas-modelRobotlegs: Discussion 2013-06-13T09:37:39Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/270754882013-05-30T10:34:26Z2013-05-30T10:34:28ZHow to properly update Datas Model ?<div><p>Hi there,</p>
<p>I use rl2 and starling for a large evolutive project and I have
some questions to work properly :</p>
<p>I use request/notification pattern to populate views via
mediators.<br>
My principal question is when view's user action is done where to
update datas?<br>
I think the right place is model. Am I right?</p>
<p>The other question is relative to the interface expose by the
model :</p>
<p>For example if my vo class is like this :<br>
ClassA_VO:<br>
+propA:String; +propB:ClassB_VO</p>
<p>ClassB_VO:<br>
+propC:String; +propD:Number;</p>
<p>If all properties are editable via user interfaces, I need to
have all this methods in my model :<br>
set currentClassAPropA<br>
set currentClassAPropB (optional)<br>
set currentClassAClassBPropC<br>
set currentClassAClassBPropD</p>
<p>And need all the commands to fire this functions?</p>
<p>Thx in advance.</p></div>harold.martintag:robotlegs.tenderapp.com,2009-10-18:Comment/270754882013-06-04T16:49:46Z2013-06-04T16:49:46ZHow to properly update Datas Model ?<div><p>Hi Harold,</p>
<p>Sorry for the late reply!!</p>
<blockquote>
<p>My principal question is when view's user action is done where
to update datas? I think the right place is model. Am I right?</p>
</blockquote>
<p>You’re right, if the data is application’s data /
application’s state. If you haven’t already, look at
Model Responsibilities:</p>
<p><a href=
"https://github.com/robotlegs/robotlegs-framework/wiki/best-practices#wiki-models">
https://github.com/robotlegs/robotlegs-framework/wiki/best-practice...</a></p>
<p>If, on the other hand, you’re referring to data
that’s only relevant for the View, like visual states,
transitions, position etc, then you most probably won’t need
to store that data into a model. But, of course, it depends on your
use case. If you’d say what kind of data you’re trying
to update, I’d give you a more specific answer.</p>
<blockquote>
<p>If all properties are editable via user interfaces, I need to
have all this methods in my model :</p>
</blockquote>
<p>I’m not sure I understand your question.<br>
Are you talking about bindable VOs in your Views?</p>
<p>Usually, a VO (value object) is a data carrier class to shuttle
typed data across tiers.<br>
A Model deals with data, data modeler, responsible for holding and
manipulating the application’s states</p>
<p>See Stray’s answers in this discussion:<br>
<a href=
"http://knowledge.robotlegs.org/discussions/questions/352-stray-clarification-on-your-model-comment-in-releaxedeventmap-docs#comment_3811552">
http://knowledge.robotlegs.org/discussions/questions/352-stray-clar...</a></p>
<p>But, again, it depends on your use case whether you need to
manipulate the VOs in a Model or directly in the View.<br>
What will happen to all the propA, propB, propC, propD after they
changed? Who needs them and when?</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/270754882013-06-06T16:50:52Z2013-06-06T16:50:52ZHow to properly update Datas Model ?<div><p>Thx a lot for the answer, some words clarify the situation.<br>
In my case datas are application's data.</p>
<blockquote>
<p>Usually, a VO (value object) is a data carrier class to shuttle
typed data across tiers. A Model deals with data, data modeler,
responsible for holding and manipulating the application’s
states</p>
</blockquote>
<p>Ok, the confusion came because i used to use Flex Framework and
data binding...</p>
<blockquote>
<p>See Stray’s answers in this discussion: <a href=
"http://knowledge.robotlegs.org/discussions/questions/352-stray-clar">
http://knowledge.robotlegs.org/discussions/questions/352-stray-clar</a>...</p>
</blockquote>
<p>Realy interesting but some thing goes unclarified for my
case.<br>
The application manage torque tools<br>
I have this 2 VO's :<br></p>
<pre>
<code>public class TorqueVO{
var value:Number;
var unit:TorqueUnitVO;
}</code>
</pre>
And :<br>
<pre>
<code>public class ToolVO{
var id:String;
var name:String;
var maxTorque:TorqueVO;
}</code>
</pre>
<p>The ToolsModel has methods to set id, name and maxTorque and the
torquesModel has methods to set value and unit.</p>
<p>There is also a view (called ToolInputView) containing an input
torque component ( a textinput for the value and a picker list for
the unit).<br>
And the mediator for this component does'nt know anything about the
tool (only the torque).</p>
<p>The question is how my ToolsModels can detects that's the
property maxTorque was updated? (I know that's the model doesn't
hear anything but a signal firing a command which call the public
method on the data model to dispatch a tool updated signal)</p>
<p>Is it the responsibility of ToolInputMediator to dispatch a
request update signal?</p>
<p>I'm not sure I'm very clear... Sorry for my poor english...</p></div>harold.martintag:robotlegs.tenderapp.com,2009-10-18:Comment/270754882013-06-07T07:54:41Z2013-06-07T07:54:41ZHow to properly update Datas Model ?<div><p>Hey Harold,</p>
<p>Don’t worry; my English isn’t perfect either ;)</p>
<p>From what you’ve described I can’t know, if you
really need 2 Models (ToolsModel and TorquesModel ) or if you could
use just one Model to manipulate the 2 VOs.</p>
<p>If you need 2 Models:</p>
<p>ToolInputMediator re-dispatches an event (or signal) on behalf
of ToolInputView. The payload would be the 2 VOs with the values
set in the view.<br>
The Command triggered by the event/signal accesses methods on
TorquesModel to update TorquesVO with the values from the
event’s payload:</p>
<p>torquesModel.value = payload.value;<br>
e.t.c.</p>
<p>If TorquesModel would have a getter for TorquesVO, then you
could access ToolsModel right away in the same command. Something
like this:</p>
<p>toolsModel.maxTorque = torquesModel.getTorquesVO;</p>
<p>Then you can dispatch an event, if need be, to inform the
mediator about the changes.</p>
<p>I hope this answers your question, but, if I misunderstood your
use case, please let me know.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/270754882013-06-07T10:19:47Z2013-06-07T10:19:47ZHow to properly update Datas Model ?<div><p>Reading your post again.</p>
<blockquote>
<p>And the mediator for this component does'nt know anything about
the tool (only the torque).</p>
</blockquote>
<p>Who knows about the Tool? Or, rather, who needs the ToolModel
after you modified it? Is it another Mediator? Are there a
ToolsView <strong>and</strong> a TorquesView, each with its own
mediator?</p>
<p>I don’t know what a Torque in your example is, but it
seems you can’t have a Tool without a Torque, right? So,
maybe before choosing a Tool, it’s mandatory to choose a
Torque first in a TorqueView? Or, is it the other way around, you
choose a Tool and then set the Torque’s values? Hehe,
I’m confused, what comes first, the tool or the
torque…?</p>
<p>Anyway, every time you’d change the Torque’s
properties, you’d modify the ToolsModel as well, and let it
or the command dispatch an event with the updated VO to the
interested parties.</p>
<p>But, maybe the workflow is completely different from what I
imagined, and you only need to let 2 Mediators communicate with
each other, say TorqueMediator dispatches an event with TorqueVO
(set in the TorqueView) as a payload, ToolsMediator is listening
for it and passes the values to its view, and after having all the
data for a Tool, including the maxTorque, it will send it to the
Model (event->command->model)?</p>
<blockquote>
<p>Is it the responsibility of ToolInputMediator to dispatch a
request update signal?</p>
</blockquote>
<p>I don’t know. Maybe. More details about the real use case
could be useful.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/270754882013-06-13T09:37:37Z2013-06-13T09:37:37ZHow to properly update Datas Model ?<div><p>I guess you’ve solved your issue. I’m closing this
discussion for now, but feel free to re-open it, if need be.</p></div>Ondina D.F.