# Creating a View Link

The View Link Wizard lets you create and edit view links. You can also create default view links, based on existing associations, by using the Business Components Project Wizard, Package Wizard, and Entity Object Wizard.

While the business components project is open, to create a view link with the View Link Wizard either:

- Choose File | New, click the Business Components tab, and double-click View Link.

- In the Workspace view of the Navigator, right-click a business components package and choose Create View Link.

When creating a view link, the wizard lets you specify the following information, listed by page:

- Name page. A view link name (pick something that describes the relationship, perhaps ending with the string "Link" to make it easy to identify) and the package the view link should be placed in.

- Association Views page. Select the source (master) view object and the destination (detail) view object, and specify a name for the destination view link accessor, and optionally generate accessors if you want to traverse the relationship in code. After the link is defined, the source view object can use the link accessor to traverse to the destination side of the link. For example, the employees of a department might be accessed through a department by issuing the call getEmps. (For default view links, the source view object contains the primary key and the destination view object contains the foreign key.)

- Role Attributes page. Select the attributes that define the relationship between the source and destination view objects of a link. (There is a separate panel for source and destination; you must specify the same number of attributes in each panel, in order.) You can optionally specify all attributes that define an association: when you shuttle an association to the Selected Attributes list, the attributes associated with that association automatically appear. Also, if you select an association in the source, the matching attributes (if applicable) will be included by default on the destination panel. These attributes are used to formulate a SQL snippet, which you can modify, if needed.

- Association SQL page. Examine the default SQL expression used to filter the records in the destination side of a view link and optionally modify it to perform any additional valid SQL restrictions. You can click Test to make sure the SQL statement is valid.

If you add an association after you have created a view object, you can manually add the link in the wizard.