Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I handle similar cases by storing the original data in an XML property of the Value Object ("VO"), and reset all of the other property values when the VO is needed.</p> <p>So, when it is first needed to be viewed, I go get the XML:</p> <pre><code>&lt;Node&gt; &lt;prop1&gt;value&lt;/prop1&gt; &lt;prop2&gt;value&lt;/prop2&gt; &lt;prop3&gt;value&lt;/prop3&gt; &lt;prop4&gt;value&lt;/prop4&gt; &lt;/Node&gt; </code></pre> <p>When I retrieve the XML, in my result handler, the first thing I do is create an instance of my VO, and set the XML property, and then call a public function in a separate class to set the VO's properties:</p> <pre><code>private function getNodeResultHandler(event:ResultEvent):void { var myNode:Node = new Node(); myNode.xmlData = new XML(event.result); nodeUtils.setNodeProperties(myNode); } public class nodeUtils { public function setNodeProperties(node:Node):void { var nodeXmlData:XML = node.xmlData; myNode.prop1 = nodeXmlData.prop1; myNode.prop2 = nodeXmlData.prop2; myNode.prop3 = nodeXmlData.prop3; myNode.prop4 = nodeXmlData.prop4; } } </code></pre> <p>Then, any time you switch your view to edit mode, you call that same function to reset the properties to the values stored in the XML.</p> <p>The only other thing you need to do is reset that XML any time the user commits changes to the VO. I usually handle this by passing back the VO's data in the same format on a Save and Get, and then saving the XML just as above.</p> <p>I usually do this in a Cairngorm MVC application, so I have event/command chains to handle all of this, but you can put this functionality in any number of classes, or in the VO class itself, whichever is easiest for you to maintain.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload