Show TOC

Procedure documentationRedirectors Locate this document in the navigation structure

 

The portal enables you to create redirectors that automatically translate all navigation targets with a specific prefix into different navigation targets.

For example, the roles connector includes a redirector (that is, a class that implements INavigationRedirector) that translates any navigation target with the pcd prefix into the same navigation target but with a ROLES prefix. This enables users or applications to navigate to role-based navigation nodes by specifying a target with a pcd prefix.

Note Note

You do not have to implement a redirector for your navigation connector. However, you can only register a redirector at the same time you register a navigation connector.

End of the note.

Procedure

The following describes how to write and deploy a redirector:

  1. Create a new class that implements INavigationRedirector.

  2. Implement the method redirect(), which has the following signature:

    Syntax Syntax

    1. public INavigationRedirectorResult redirect(
              String atomicName, Hashtable hashtable) throws NamingException {
      }
      
    End of the code.

    The original navigation target is passed as a string, without a prefix or separator.

    The method provides the logic for translating this string into the new navigation target, including a prefix and separator. The method returns an object of type INavigationRedirectorResult. You must create a class that implements this interface.

  3. Package this class with the PAR file that contains your navigation connector.

  4. Register the redirector in the same call that registers your navigation connector, as follows

    1. Create an instance of your redirector.

    2. Create a Map for holding your redirectors.

    3. Register your redirector when registering your connector.

Syntax Syntax

  1. private myConnectorRedirector myConnectorRedirector;
    
    // Create instance of redirector.
    public void init(IServiceContext serviceContext) {
       myConnectorRedirector = new myConnectorRedirector();
    }
    
    // Register redirector.
    public void afterInit() {
    
        INavigationConnectorRegistration service =
            (INavigationConnectorRegistration) getContext().
                getService(INavigationService.KEY);
        if (service != null) {
            Map redirectors = new HashMap();
            redirectors.put("myRedirectPrefix",myConnectorRedirector);
    
            service.registerConnector(
                "myRedirectPrefix",myConnector,null,redirectors);
        }
    }
    
End of the code.