Portlet Factory, Version 6.1.2


 

Breadcrumbs builder

The Breadcrumbs builder places a list of links to visited pages on a page in your model. Each link is called a breadcrumb.

In the context of this builder, a page that is associated with a breadcrumb can be a page in the model or a page of data. The links, called breadcrumbs, provide a mechanism for users to return to pages that they displayed in the application. Use this builder to put a breadcrumbs element on a page. A breadcrumbs element is a list of links that represents where the user has visited, with the ability to go the previously visited links. The pages that are saved as breadcrumbs can be either of the following:

  • Actual pages in the model

  • Data in the form of a key

When dealing with navigating a tree of data, you can use different model pages to display different items. For example, consider a catalog that has multiple groups, including groups within groups that lead to individual items. You might have one model page that is used for displaying a group (with its subgroups and items that it contains) and a different model page for displaying items. This approach is easily supported.

Breadcrumbs are usually placed across the top of a page and indicate the navigation path that the user followed to the current page. Using breadcrumbs, the user can easily backtrack to a previous page by clicking a breadcrumb.

The currently selected level in the breadcrumbs is text, that is, the current page does not have a link to itself. Because clicking the current level does not change the navigation, only the previous levels are links. Specify a separator between levels of the breadcrumbs to clearly illustrate the link intervals. You can specify some text to display before the breadcrumb.

This builder requires only one tag per page location on all pages that will contain the display of the breadcrumbs. You can have the display on all pages that participate in the breadcrumbs. In this case, a user who visits one of the pages creates a breadcrumb in the list. Or you can have this display only on a single page that wraps other pages, for example, by using an Inserted Page builder. The following sections describe the use of the builder:

 

Requirements to use the builder

The following are the requirements for using this builder:

 

About navigating through model pages

In this technique, you use breadcrumbs so that the users can see how they arrived at the current page and can easily return to a previously visited page. For this technique, the selector is simply the name of the page. The preparePage method is not required to perform any other action to prepare the page. The key is the name of the model page.

If you leave the entry for the Prepare Page Method input blank, a default method is created that takes the name of the page as the name of the action to run and no preparations are done. This default method works very well if your application consists of multiple model pages that users visit.

For the Get Text Method input, specify the text that is displayed for the breadcrumbs element in the list. If you leave this input blank, the name of the method that returns the key is displayed to describe the link to that page. This input lets you supply more readable names for the pages. You can use a Localized Resource builder that includes page names as the keys and readable names as the values. The Localized Resource builder has an advanced input that creates a method that you can specify in the Get Text Method input of this builder. Alternatively, you can write a method that uses conditional statements to return the correct readable name for each possible page name.

 

About navigating through data

Another common use for breadcrumbs helps users save their places as they navigate through data, for example, the categories and groups within an online catalog. In the technique for implementing this use, perhaps only a single page in a model is ever displayed. However, each breadcrumb has different data (probably from a database query or a service) with which it is currently associated. For example, one breadcrumb can be associated with sporting goods, and another with basketball equipment; but the same page in the model actually displays either of these breadcrumbs.

The following are the considerations in using this technique:

 

Advanced navigation through data

If the model navigates through data (see About navigating through data), you can have different model pages display different types of data, for example, one for major categories, another for groups of items, and another for individual items. This technique is supported by having the preparePage method return different actions depending on the type of breadcrumb element being displayed. For example, all major categories can be displayed using MyCategoryPage, all groups of items with MyGroupPage, and all individual items with MyItemPage.

To implement this technique, modify the preparePage method to do the following processing:

  • From the unique key, identify which type of element is involved.

  • Fetch the data that is associated with the unique key.

  • Return one of several different strings depending on the type of data selected by the unique key. For example, MyCategoryPage, MyGroupPage, or MyItemPage.

 

A data provider class

Sometimes a simple string is not adequate as a key to identify data. For the model to be efficient, it might need to cache more information, possibly the entire set of data. However, when the breadcrumbs links are created, a string is still required to represent the breadcrumb element that the user clicks. This string might be temporary, and last as long as a breadcrumb is active. But it must be a string to be able to be encoded in the URL in the link. This mode of operation requires that you create a DataProvider class.

The following requirements must be met:

The Breadcrumbs builder creates the method that instantiates your DataProvider instance. The constructor that the builder invokes can be one of the following forms:

  • Takes zero arguments

    Use this if you left the preparePage and getText inputs blank.

  • Takes two arguments

    The arguments are the two strings that you specify in the preparePage and getText inputs.

Specify this class in the Data Provider Class Name input of the builder.

Set the Use Empty Constructor input to specify which constructor is invoked.

Parent topic: Builder help


Library | Support |