skip to main content
TGO > Programmers documentation > Integrating with JViews Diagrammer > Attribute binding > How to implement attribute binding
 
How to implement attribute binding
The abstract class IlpAbstractAttributeBinding defines the base for an attribute binding. It requires a binding type (READ-ONLY or READ-WRITE), the JViews TGO attribute name and corresponding data type, and the SDM property name and corresponding data type. The class provides APIs that must be extended to implement the logic behind attribute binding.
The default binding implementation (IlpDefaultAttributeBinding) defines a pass-through READ-WRITE binding type between a given attribute and an SDM property of the same name and data type. For example, the default binding can be used to map the JViews TGO name attribute (type String) to the SDM name property (type String).
Binding context
The following binding method is available for subclasses to access contextual information about the current binding:
protected IlpAttributeBindingContext getBindingContext()
The IlpAttributeBindingContext is set to the binding object right before performing a type conversion. It is used to provide the following required information:
*JViews TGO context (IlpContext)
*Java Logger for message and error logging
*Current attribute holder (JViews TGO object) to which the conversion applies
*Current attribute value
*Current property value
After the conversion, the context object is removed from the binding object.
Object convertToProperty(Object): This method applies READ-WRITE and READ-ONLY binding types. It must be extended to implement the conversion of a JViews TGO attribute to an SDM property. The given argument is the current JViews TGO attribute and the returned value corresponds to the new SDM property value. The method getBindingContext() can be invoked inside this method to retrieve contextual information that might be valuable for the conversion.
Object convertToAttribute(Object): This method only applies to READ-WRITE binding types. It must be extended to implement the conversion of an SDM property to a JViews TGO attribute. The given argument is the current SDM property value and the returned value corresponds to the new JViews TGO attribute value. The method getBindingContext() can be invoked inside this method to retrieve contextual information that might be valuable for the conversion.
How to set bindings to different JViews TGO classes
// Get the reference to your bindings
IlpAbstractAttributeBinding bindingOne = ...
IlpAbstractAttributeBinding bindingTwo = ...
 
// Get the reference to your adapter
IlpAbstractSDMAdapter adapter = ...
 
// Add 'bindingOne' to all predefined business objects
adapter.addAttributeBinding(IltObject.GetIlpClass(), bindingOne);
 
// Add 'bindingTwo' only to predefined 'network element' objects
adapter.addAttributeBinding(IltNetworkElement.GetIlpClass(), bindingTwo);

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.