Dynamic View Services > Specifying Dynamic View Types > Basic Specification > Editing the Tree Representation
 
Editing the Tree Representation
Implementing a Representation Model explains how to notify the server of editing operations directly performed by the component on representation objects. This section explains the conditions under which a component can update a representation object directly and how it affects the associated server object. For example, let us examine how editing the label of a tree gadget item in the component affects the name of the department associated with this item in the server.
This is the code of the callback function onSetLabel:
void TreeItemR::onSetLabel(IlsString value)
{
   IlsRpAttributeId attrId=getAttributeId("label");
   if ((attrId>=0) && (isEditable(attrId)){
    onUpdate(attrId,value);
   }
}
We assume this function is called through a callback mechanism supplied by the graphic layer whenever the label of a tree item gadget is modified by the user.
In our example, the label attribute is editable for the following reasons:
*In the specification of CompanyTree, the name attribute of a Department server object is directly mapped to the label attribute of its associated item representation:
subscribe Department:
represent TreeItemR item:
...
string label=name;
*The runtime attribute name of a Department object is editable because it is associated with a modifier which is the implicit assignment operator of IlsEntry: ILS_ENTRY_STRING(Department,name).
Executing the function TreeItemR::onSetLabel sends an update request to the server. On the server side, the identifier of the item representation object found in the request is used to retrieve the department involved. Then, the modifier registered with the runtime attribute name of the object Department is executed by the view interpreter, and passes the value received in the request as a parameter.
The member function IlsRpObject::onUpdate called on a representation attribute fails and returns IlsFalse if:
*The attribute is not referenced in the representation specification.
*The expression of the representation attribute is not directly mapped to a runtime attribute (See “Expression of Representation Attributes”..)
*The attribute is mapped directly but the server runtime attribute is not associated with any modifier (for instance, when it depends on a derived data member).
In such occurrences, the update request is rejected locally at component level and is not sent to the server. To avoid this, the function IlsRpObject::isEditable should be called before trying to edit a representation attribute.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.