Extending the Mapping
The classes IlsSwRepresentation, IlsSwTable and IlsSwRow instantiate representation objects because they derive from IlsRpObject. They contain a predefined mapping for representation object attributes such as title, column[ ], foregound[ ], and others. If you want to extend this mapping to handle your own representation attributes, you must derive the Server/Views representation classes and install your own representation attributes.
As these classes instantiate representation objects, they are not created by the Server/Views component, but by the generic part, mvcomp. The main difference is that the server knows about these representation types and creates them to represent existing server objects. The only way to derive these classes is:
To declare them on the server side through special macros. Otherwise, the component will not know which attributes are inherited from their parent class.
For example, suppose you want to create a subclass of IlsSwRow with an additional attribute time. If you use the standard macros to map this type, like this:
ILS_RP_OBJECT_BEGIN(MyRow)
ILS_RP_ATTR_STRING(MyRow,time,setTime)
ILS_RP_OBJECT_END(MyRow)
the component can assign the attribute time but fails if a standard IlsSwRow attribute assignment is attempted (for example, table, its parent). Instead, use the following macros:
ILS_RP_OBJECT1_BEGIN(MyRow,IlsSwRow)
ILS_RP_ATTR_STRING(MyRow,time,setTime)
ILS_RP_OBJECT_END(MyRow)
Now, the component knows which attributes are inherited by this class and can use those of the class IlsSwRow.
To specify a representation that uses this new type in the configuration
.ils/
.ilv files that are statically or dynamically read by the server, like this:
subscribe Origin:
represent MyRow:
mandatory Ref<IlsSwTable> table=the_table;
string time=object.time; # this is the new attribute
#...
The macro ILS_RP_OBJECT1_BEGIN(derivedClass,baseClass) allows you to declare a subclass of IlsRpObject so that the mappings declared on the parent class are inherited. For example:
ILS_RP_OBJECT1_BEGIN(ColorRow, IlsSwRow)
ILS_RP_ATTR_STRING(ColorRow, rowColor, setRowColor)
ILS_RP_OBJECT_END(ColorRow)
This code sample defines a mapping for a subtype of IlsSwRow with an additional attribute rowColor mapped to the function setRowColor.
You can introduce your new type in the dynamic view specification using Rogue Wave Server Studio. If you choose to do so, you must follow specific rules for your new subtypes to be recognized by Rogue Wave Server Studio. See
Using Studio with Derived Representation Object Types for more information.
Warning: The classes IlsSwRepresentation, IlsSwTable and IlsSwRow override a number of virtual member functions of the classes IlsRpObject and IlsRepresentation. If you override these functions in your own subtypes, you must also call the functions of the parent class. |
Your own representation object class may want to interact with Rogue Wave Views data sources. The base classes provides a complete API to retrieve data sources and memory table:
IlsSwTable::getMainDataSource IlsSwTable::getPropertyDataSource and to update the Views data sources:
IlsSwTable::setPropertyCell IlsSwRow::setCell You should use these methods to conform to the rules of the Server/Views mapping when updating the data sources. For instance, the function setCell does not assign the value to the data source immediately but buffers that value until the end of notification for this row.
Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.