Scope of document covers communication protocol between Model and Controller
in
References: Server object (POJO|POCO) - XML synchronization.
Protocol selection choice.
Usual pattern is to use XML for server-client communication and XQuery for client to server. While that is well-known and
developed pattern, it involves extra protocol (XQuery)
and protocol data synchronization on client side. By using DiffXml we keep same
data format in both directions and most of transaction types will have same
data format(when request equal response). On back-end implementation
DiffXml could be used as subset of XQuery to perform
server data resided in XML DB. For server plain old XXX object model, XML
serialization implementation will perform transactional activity.
All updates data are in XML format matching server-side object
serialization.
FullXml is passes as part of initial display or complete re-render.
DiffXml is subset of full one which includes only one or several fields
to be updated (partial xml serialization). It could include additional info
next to the field, like validation error code/message or suggested values. It
also used for operations: List, Update, Delete.
·
List/Create.
If DiffXml send in request response shall fill out 1 level of details for
deepest requested node. If object does not exist, it will be created.
Deep object data could be retrieved by sequential calls:
o request: <A><B/></A>
o response: <A><B><Field1>1</Field1><D/></B></A>
next level
o request: <A><B><D/></B></A>
o response: <A><B><D><XXX-array length=”10”/></D></B></A>
·
· Update. Updated field(s) value is sent as DiffXml. Controller on model side validates and returns DiffXml with new value and error attributes if any.
· Delete. In request object’s node is marked with attribute deleted=”1”, response confirms by preserving this attribute. If object can not be deleted, deleted=”false” and error attributed attached to node in response.
Samples include: POJO on back-end, JSP/servlet on Controller, DHTML on View.
Other configurations like RDBMS–ASP.
o Set of three DiffXml instances. Could be created onFocus.
§ CurrentUiState. It will be posted to server. After response - same as server last response.
§ ServerSideState. Updated only if no error in response.
§ ServerLastResponse.
Initially matching original obj.field value, they will be used for change notification from UI(onBlur) to server side(XHR) :
Array is an ordered collection of same (sub-)type elements. Each element have to have unique in array id as attribute. If attribute is not present, controller will render id as 1-based number in array (i.e. first element has id=1, secnd has id=2... ).
DiffXml request with element without id.
Respoce will return DiffXml with fields and defined id.
request: <XXX-aray><EL/></XXX-array>
response: <XXX-aray><EL id="3"><field1>val1</field1></EL></XXX-array>
View
does not have element with newly id. Array UI shall inject the element.
Same as regular object: DiffXml has array element node with deleted=”1” attribute. Response gives back identical DiffXml if proceeded well, otherwise deleted=”0” and error code attached to removable node.
Sample object XML:
<artist>
<recordings
length=”5” >
<recording
id=”1”>
<title>Swan
song</ title >
<tracks/>
On each request only single level of embedded objects is available. Session sequence:
1. request:
<artist/>
response: <artist>…<recordings
length=”5” ></artist>
2. request: <artist><recordings/></artist>
response: <artist><recordings><recording id=”1” />…<recording
id=”5” /></recordings></artist>
3. request: <artist><recordings><recording
id=”3” /></recordings></artist>
response: <artist><recordings><recording
id=”3” ><title>3rd
title</title><tracks length=”8”/></recording></recordings></recordings></artist>
4. continues to tracks, than <track id=”XXX”/>
4.4 Pagination
No special pagination support is given. The total number of elements in array is given by length attribute. Retrieval of partial content is done by DiffXml with only required elements listed. If Model supports array element ID matching the order number, retrieval of page content is the DiffXml request with array element nodes having ID starting from first element on the page till last page element.