Site Navigation:


A binding example using inheritance

The SoftBean object model

We get a drawing which is a collection of abstract Forms. We cannot instantiate directly this object but we must instantiate objects of sub-classes, according to the "type" property.

The target XML format



<Shape type="CIRCLE">





<Shape type="RECTANGLE">






The binding specification\



Here the 2nd binding rule adds a type specifier between { and }. It is used when creating Shape sub-objects to the property "theShapes" of the Drawing object. This is a collection of rules giving:

  • the class to be instantiated

  • the XML attribute providing information to switch between different rules

  • the value of this XML attribute

The only possibility to switch between rules is to provide a XML attribute in the XML element of the sub-object. If not, it would not be possible for the XML parser to know which object it is handling, and which binding rules to use.