What Is a View Link?

A view link defines a relationship between view objects. The relationship can be one-to-one, one-to-many, many-to-one, or many-to-many. The View Link Wizard and Editor lets you specify source and destination view objects, and links them using attributes selected from the view objects.

Examples of view links

An example of a one-to-many relationship could be a DepartmentsOverBudgetView view object linked to a ContractorView view object in a master-detail relationship. With this view link, you could efficiently look at information about contractors in overbudget departments.

An example of a more complex one-to-many relationship could be a CustomerView view object linked to an OrderView view object in a master-detail relationship, and the OrderView view object linked to an ItemView view object in a master-detail relationship. So a user could quickly look at the items in a particular customer's order in one form.

View links can be created based on associations

View links can be created based on associations, but an association is not needed to use a view link. A view link is similar to an association, but more flexible. It allows more relationships than equality between attributes and supports automatic master-detail synchronization.

Note that if a view link is based on an existing association, and the association has been defined as a composition, then when creating a detail view row, the master view row must exist and have non-null key values. If the association has not been defined as a composition, no such restriction applies.

Tools help you create view links

You can define and edit view links in the View Link Wizard and Editor.

You can also generate default view links, based on existing associations, by using the Entity Object Wizard and Editor, Business Components Project Wizard, or Package Wizard.

View link navigation and relationships are customizable

View links are navigable in one direction (master to detail, not detail to master) or both directions. If the default relationship based on attribute equality does not provide adequate functionality, you are able to create complex SQL-based relationships by specifying a Where clause in the Association SQL panel of the View Link Wizard or Editor.

If a view object is specified as a detail view in a link, the view object further restricts the data to the detail information (by adding the Where clause specified in the Association SQL panel to the SQL statement that defines the view object). In other words, a view link selects a correlated view of underlying data based on bind values supplied by the current row of the master view.

Detail row sets are automatically coordinated with the master row set

When two view objects, related through a master-detail view link, are in an application module, the default (or first) iterator for the master view object automatically changes the detail rowset when the master row changes. When the detail view object is created, the business component framework registers it as an event listener for the master's iterator. So, when the iterator moves to another row in the master iterator, the detail view object receives the event and automatically refers to the appropriate detail rowset.

View links can be included in an application module's data model

A view link can be included in one or more applications modules, or not. You can reuse view links in multiple application modules.

Accessor methods let you traverse view links

You can use the View Link Wizard and Editor to create optional accessor methods in the source view object (the ViewRow class) and possibly the underlying source entity object. You can use these accessor methods to traverse the view link to programmatically access a desired result set in the view object. The accessors let you gather data from other view objects, returning a rowset from the other view object. They also let you get and set attributes at the destination end of the view link. You can access them programmatically even if the view link is not part of an application module.

View links can be dynamically created

You can create view links dynamically at runtime using the createViewLink methods of the ApplicationModule interface.