Redirectors
Use
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.
Procedure
The following describes how to write and deploy a redirector:
-
Create a new class that implements INavigationRedirector .
-
Implement the method redirect() , which has the following signature:
public INavigationRedirectorResult redirect( String atomicName, Hashtable hashtable) throws NamingException { }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.
-
Package this class with the PAR file that contains your navigation connector.
-
Register the redirector in the same call that registers your navigation connector, as follows
-
Create an instance of your redirector.
-
Create a Map for holding your redirectors.
-
Register your redirector when registering your connector.
-
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);
}
}