Provides functionality to construct URLs based on the state of one or more commands or data sources, and to initialize commands and datasources from state encoded in a URL.

Namespace:  Endeca.Web.Url
Assembly:  Endeca.Web (in Endeca.Web.dll) Version: 2.1.3.0 (2.1.3.622)

Syntax

C#
public class UrlManager
Visual Basic (Declaration)
Public Class UrlManager
Visual C++
public ref class UrlManager

Remarks

UrlManager provides the following capabilities:
  • Registering commands and data sources with a manager so that that the URLs that are generated represent the combined state of these objects.
  • Generating URLs representing the state of the commands and datasources registered with the manager.
  • Initializing the state of registered commands data sources from by deconstructing a URL.

An application can obtain an instance of a UrlManager by calling Get(String). Once the instance is obtained, commands and data sources can be registered by calling Register(ICommandSource). Note that UrlManager is able to handle data sources and commands in a uniform fashion through the use of the ICommandSource interface. All the standard Endeca commands and data sources implement this interface.

Once commands and data sources have been registered with a manager, URLs can be generated by calling methods on the UrlBuilder object available from the Urls property. Refer to the documentation for UrlBuilder for further details.

Note that the specific algorithm used for encoding and decoding the state of EndecaCommands to and from URLs is represented by an instance of the UrlProvider class. Each UrlManager is associated with a UrlProvider by the UrlProvider property. This property will return a BasicUrlProvider instance by default; applications may customize this by assigning a different UrlProvider implementation if necessary.

In addition to generating URLs, the commands and data source registered with a UrlManager can be initialized from a URL (previously generated by a UrlBuilder). The InitializeFrom(Uri) method acccepts a URL, and updates the state of the commands and data sources registered with the manager to reflect the state encoded in the URL. The algorithm for decoding the state is represented by the UrlProvider associated with the manager.

Examples

The following example illustrates how to obtain a UrlManager and construct URLs.
CopyC#
// Code similar to this method should be performed early in the page lifecycle; typically
// during Init or Load.
public string InitializeUrlManager( NavigationDataSource dsNav ) 
{
  // Obtain a manager with the ID "MyMgr".  Get() creates a new manager if
  // necessary.
  UrlManager mgr = UrlManager.Get("MyMgr");

  // Register the data source with the manager
  mgr.Register(dsNav);

  // Initialize the data source with state from the current URL
  mgr.InitializeFrom(HttpContext.Current.Request.Url);
}

// Code similar to this method is usually called during data binding
public string BuildSelectDimensionValueUrl( DimensionValue dimVal ) 
{
  // Obtain the UrlManager
  UrlManager mgr = UrlManager.Get("MyMgr");

  // Build a URL reflecting the state when the dimension value is selected
  return mgr.Urls.BuildUrl( delegate( CommandActionInfo i) {
     // Obtain a copy of the command associated with dsNav
     NavigationCommand cmd = i.Get<NavigationCommand>("dsNav");

     // Select the dimension value
     cmd.SelectDimensionValue( dimVal );
  } );

  // Note that UrlBuilder.SelectDimensionValue() is a convenient helper method that is 
  // equivalent to the above call.
}

// This method shows how to link to a different page from the current page
public string BuildRecordDetailsUrl( Record record )
{
   // Obtain a UrlManager
   UrlManager mgr = UrlManager.Get("details");

   // Set BaseUrl to point to the page that displays record details
   mgr.BaseUrl = "~\RecDetails.aspx";

   // Register a RecordDetailsCommand.  Note that this command is not executed when building
   // URLs, so it is not necessary to set the connection.
   RecordDetailsCommand detailsCmd = new RecordDetailsCommand();
   detailsCmd.ID = "details";
   mgr.Register( detailsCmd );

   // Construct the URL using one of the high-level convenience method of UrlBuilder.
   return mgr.Urls.SelectRecord( "details", record );
}

Inheritance Hierarchy

System..::.Object
  Endeca.Web.Url..::.UrlManager

See Also