Index: Dev/branches/rest-dojo-ui/client/rft/pages/questions.js
===================================================================
--- Dev/branches/rest-dojo-ui/client/rft/pages/questions.js	(revision 292)
+++ Dev/branches/rest-dojo-ui/client/rft/pages/questions.js	(revision 303)
@@ -1,6 +1,6 @@
 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/_base/event',
-    'dojo/_base/Deferred','dojo/dom-construct','dojo/store/JsonRest','dijit/layout/ContentPane','dijit/TitlePane',
+    'dojo/_base/Deferred','dojo/dom-construct','rft/store','dijit/TitlePane',
     'rft/ui/_Page','rft/ui/LineWithActionsWidget'],
-    function(declare,lang,array,event,Deferred,domConstruct,JsonRest,ContentPane,TitlePane,_Page,LineWithActionsWidget) {
+    function(declare,lang,array,event,Deferred,domConstruct,store,TitlePane,_Page,LineWithActionsWidget) {
         return declare('rft.pages.questions',[_Page],{
             constructor: function() {
@@ -9,12 +9,10 @@
             },
             onVisit: function() {
-                this._store = new JsonRest({
-                    target:"../server/api.php/data/Question/",
-                    idProperty: 'uid'
-                });
+                this._store = store.getStore('Question');                
                 this._refresh(true);
             },
             _refresh: function(initial) {
-                Deferred.when( this._store.query() ).then(lang.hitch(this,function(results){
+                Deferred.when( this._store.query() )
+                .then(lang.hitch(this,function(results){
                     array.forEach(results,lang.hitch(this,'_addQuestion'));
                     initial && this.accordion.selectChild(true);
@@ -22,5 +20,5 @@
             },
             _addQuestion: function(q) {
-                var uid = q.uid;
+                var uid = q.getUid();
                 var question = this.questions[uid];
                 if ( !question ) {
@@ -54,5 +52,5 @@
                 var placeNode = this.accordion.domNode;
                 var placePos = 'last';
-                array.some(widgets,lang.hitch(this,function(widget,idx) {
+                array.some(widgets,lang.hitch(this,function(widget) {
                     if ( widget.title == category ) {
                         containerWidget = widget;
Index: Dev/branches/rest-dojo-ui/client/rft/pages/sessions.html
===================================================================
--- Dev/branches/rest-dojo-ui/client/rft/pages/sessions.html	(revision 292)
+++ Dev/branches/rest-dojo-ui/client/rft/pages/sessions.html	(revision 303)
@@ -24,5 +24,4 @@
             var submitHandler = lang.hitch(that,function(evt){
                 var newObj = this.form.get('value');
-                debugger;
                 // mixin newObj in obj.
                 // store.put(newObj);
Index: Dev/branches/rest-dojo-ui/client/rft/pages/survey.html
===================================================================
--- Dev/branches/rest-dojo-ui/client/rft/pages/survey.html	(revision 292)
+++ Dev/branches/rest-dojo-ui/client/rft/pages/survey.html	(revision 303)
@@ -1,4 +1,5 @@
 <div data-dojo-type="rft.pages.survey">
     <h1 data-rft-attach-point="header">(default)</h1>
+    <div>Created by <span data-rft-attach-point="creator"></span><div>
     <form data-dojo-type="dijit.form.Form" data-rft-attach-point="form" data-rft-attach-event="onSubmit:onSave">
         <div style="display: block; clear: both;">
Index: Dev/branches/rest-dojo-ui/client/rft/pages/survey.js
===================================================================
--- Dev/branches/rest-dojo-ui/client/rft/pages/survey.js	(revision 292)
+++ Dev/branches/rest-dojo-ui/client/rft/pages/survey.js	(revision 303)
@@ -1,12 +1,9 @@
-define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/event','dojo/_base/Deferred','dojo/store/JsonRest','rft/ui/_Page'],
-    function(declare,lang,event,Deferred,JsonRest,_Page){
+define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/event','dojo/_base/Deferred','rft/store','rft/ui/_Page'],
+    function(declare,lang,event,Deferred,store,_Page){
         return declare('rft.pages.survey',[_Page],{
             object: null,
             postCreate: function() {
                 this.inherited(arguments);
-                this._store = new JsonRest({
-                    target:"../server/api.php/data/Survey/",
-                    idProperty: 'uid'
-                });
+                this._store = store.getStore('Survey');
             },
             onVisit: function() {
@@ -16,4 +13,8 @@
                         this.object = obj;
                         this.setFields(obj);
+                        return Deferred.when( obj.creator && store.dereference(obj.creator) );
+                    }))
+                    .then(lang.hitch(this,function(obj){
+                        this.creator.innerHTML = (obj && obj.email) || 'unknown';
                     }));
                 } else {
Index: Dev/branches/rest-dojo-ui/client/rft/pages/surveys.js
===================================================================
--- Dev/branches/rest-dojo-ui/client/rft/pages/surveys.js	(revision 292)
+++ Dev/branches/rest-dojo-ui/client/rft/pages/surveys.js	(revision 303)
@@ -1,11 +1,8 @@
-define(['dojo/_base/declare','dojo/_base/lang','dojo/store/JsonRest','dojo/data/ObjectStore','rft/content','rft/ui/_Page'],
-    function(declare,lang,JsonRest,ObjectStore,content,_Page){
+define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/Deferred','dojo/data/ObjectStore','rft/auth','rft/store','rft/content','rft/ui/_Page'],
+    function(declare,lang,Deferred,ObjectStore,auth,store,content,_Page){
         return declare('rft.pages.surveys',[_Page],{
             selectedObject: null,
             postCreate: function() {
-                this._store = new JsonRest({
-                    target:"../server/api.php/data/Survey/",
-                    idProperty: 'uid'
-                });
+                this._store = store.getStore('Survey');
             },
             onVisit: function() {
@@ -14,15 +11,16 @@
                 this.grid.on('rowclick',lang.hitch(this,function(evt){
                     this.selectedObject = evt.grid.getItem(evt.rowIndex);
-                    this.btnEdit.set('disabled',!!this.selectedObject);
+                    this.btnEdit.set('disabled',!this.selectedObject);
                 }));
 
                 this.grid.on('rowdblclick',lang.hitch(this,function(evt){
                     var obj = evt.grid.getItem(evt.rowIndex);
-                    content.goTo('/survey',{uid:obj.uid});
+                    content.goTo('/survey',{uid:obj.getUid()});
                 }));
-                
+                                
                 this.btnNew.on('click',lang.hitch(this,function(){
-                    this._store.add({},function(obj) {
-                        content.goTo('/survey',{uid:this.selectedObject.uid});
+                    Deferred.when( this._store.add({'creator':auth.getUser()}) )
+                    .then(function(obj) {
+                        content.goTo('/survey',{uid:obj.getUid()});
                     });
                 }));
@@ -30,5 +28,5 @@
                 this.btnEdit.on('click',lang.hitch(this,function(){
                     if ( this.selectedObject ) {
-                        content.goTo('/survey',{uid:this.selectedObject.uid});
+                        content.goTo('/survey',{uid:this.selectedObject.getUid()});
                     }
                     
Index: Dev/branches/rest-dojo-ui/client/rft/store.js
===================================================================
--- Dev/branches/rest-dojo-ui/client/rft/store.js	(revision 303)
+++ Dev/branches/rest-dojo-ui/client/rft/store.js	(revision 303)
@@ -0,0 +1,68 @@
+define(['dojo/_base/lang','dojo/_base/array','dojo/_base/Deferred','dojo/store/JsonRest'],
+    function(lang,array,Deferred,JsonRest){
+    
+        var OBJ_TYPE = '__objectType';
+        var OBJ_UID = '__objectUid';
+        var REF_TYPE = '__referenceType';
+        var REF_UID = '__referenceUid';
+
+        var RftObject = function(values) {
+            var self = this;
+            lang.mixin(this,values);
+            self.getUid = function() {
+                return self[OBJ_UID];
+            }
+        };
+    
+        var rftStoreCtor = function(objectType) {
+            var jsonStore = new JsonRest({
+                target:"../server/api.php/data/"+objectType+"/",
+                idProperty: OBJ_UID
+            });
+            return lang.delegate(jsonStore,{
+                query: function(query, directives){
+                    return Deferred.when( jsonStore.query(query,directives), function(results){
+                        return array.map(results,function(result){
+                            return new RftObject(typeof result == "object" ? result : object);
+                        });
+                    });
+                },
+                get: function(id, directives){
+                    return Deferred.when( jsonStore.get(id,directives), function(result){
+                        return new RftObject(typeof result == "object" ? result : object);
+                    });
+                },
+                add: function(object, directives){
+                    return Deferred.when( jsonStore.add(object,directives), function(result){
+                        return new RftObject(typeof result == "object" ? result : object);
+                    });
+                },
+                put: function(object, directives){
+                    return Deferred.when( jsonStore.put(object,directives), function(result) {
+                        return new RftObject(typeof result == "object" ? result : object);
+                    });
+                },
+                remove: function(id, directives){
+                    return jsonStore.remove(id,directives);
+                }
+            });
+        };
+    
+        var storeCache = {};
+    
+        return {
+            getStore: function(objectType) {
+                if ( !storeCache[objectType] ) {
+                    storeCache[objectType] = new rftStoreCtor(objectType);
+                }
+                return storeCache[objectType];
+            },
+            dereference: function(object) {
+                if ( object[REF_TYPE] ) {
+                    return this.getStore(object[REF_TYPE]).get(object[REF_UID]);
+                }
+                return object;
+            }
+        };
+
+    });
Index: Dev/branches/rest-dojo-ui/client/rft/ui/QuestionWidget.js
===================================================================
--- Dev/branches/rest-dojo-ui/client/rft/ui/QuestionWidget.js	(revision 292)
+++ Dev/branches/rest-dojo-ui/client/rft/ui/QuestionWidget.js	(revision 303)
@@ -1,26 +1,32 @@
-define(['dojo/_base/declare','dojo/dom-construct','dijit/_WidgetBase',
+define(['dojo/_base/declare','dojo/_base/lang','dojo/dom-construct','dijit/_WidgetBase',
     'dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin',
     'dojo/text!./templates/QuestionWidget.html','dijit/form/TextBox',
     'dijit/form/Textarea','./MultipleChoiceWidget'],
-    function(declare,domConstruct,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString,TextBox,Textarea,MultipleChoiceWidget){
+    function(declare,lang,domConstruct,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString,TextBox,Textarea,MultipleChoiceWidget){
         return declare('rft.ui.QuestionWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
             templateString: templateString,
             mode: 'view', // view || edit
             name: '',
+            value: null,
             _type: null,
             _widgetCache: null,
             constructor: function() {
                 this.inherited(arguments);
+                this.value = {};
                 this._widgetCache = {};
             },
             postCreate: function() {
+                this._resetValue = this.value;
                 this.typeSelector.set('disabled', this.mode == 'edit');
             },
             _setValueAttr: function(value) {
-                value.type && this._onTypeChange(value.type);
+                this.value = value;
+                this._onTypeChange(value.type || 'string');
                 this.ourForm.set('value',value);
             },
             _getValueAttr: function() {
-                return this.ourForm.get('value');
+                var value = this.ourForm.get('value');
+                lang.mixin(this.value,value);
+                return this._question;
             },
             _onTypeChange: function(type) {
@@ -60,4 +66,8 @@
                 }
                 return widget;
+            },
+            reset: function() {
+                this.ourForm.reset();
+                this._setValueAttr(this._resetValue);
             }
         });
Index: Dev/branches/rest-dojo-ui/client/rft/ui/templates/QuestionWidget.html
===================================================================
--- Dev/branches/rest-dojo-ui/client/rft/ui/templates/QuestionWidget.html	(revision 292)
+++ Dev/branches/rest-dojo-ui/client/rft/ui/templates/QuestionWidget.html	(revision 303)
@@ -2,5 +2,4 @@
     <form data-dojo-type="dijit.form.Form" data-dojo-attach-point="ourForm">
         <fieldset>
-            <input data-dojo-type="dijit.form.TextBox" name="uid" type="text" class="dijitHidden" />
             <label for="code" class="loginLabel">Code</label>
             <input data-dojo-type="dijit.form.TextBox" name="code" type="text" class="loginInput" />
