use of org.alfresco.web.config.NavigationConfigElement in project acs-community-packaging by Alfresco.
the class AlfrescoNavigationHandler method handleDispatch.
private void handleDispatch(FacesContext context, String fromAction, String outcome, Node dispatchNode) {
if (dispatchNode != null) {
if (logger.isDebugEnabled())
logger.debug("Found node with type '" + dispatchNode.getType().toString() + "' in dispatch context");
// get the current view id
String viewId = context.getViewRoot().getViewId();
// see if there is any navigation config for the node type
ConfigService configSvc = Application.getConfigService(context);
NavigationConfigElement navigationCfg = null;
try {
Config nodeConfig = configSvc.getConfig(dispatchNode);
navigationCfg = (NavigationConfigElement) nodeConfig.getConfigElement(NavigationElementReader.ELEMENT_NAVIGATION);
} catch (InvalidNodeRefException e) {
if (logger.isDebugEnabled())
logger.debug("Invalid node reference: " + dispatchNode);
}
if (navigationCfg != null) {
// see if there is config for the current view state
NavigationResult navResult = navigationCfg.getOverride(viewId, outcome);
if (navResult != null) {
if (logger.isDebugEnabled())
logger.debug("Found navigation config: " + navResult);
if (navResult.isOutcome()) {
navigate(context, fromAction, navResult.getResult());
} else {
String newViewId = navResult.getResult();
if (newViewId.equals(viewId) == false) {
if (logger.isDebugEnabled())
logger.debug("Dispatching to new view id: " + newViewId);
goToView(context, newViewId);
} else {
if (logger.isDebugEnabled())
logger.debug("New view id is the same as the current one so setting outcome to null");
navigate(context, fromAction, null);
}
}
} else {
if (logger.isDebugEnabled())
logger.debug("No override configuration found for current view or outcome");
navigate(context, fromAction, outcome);
}
} else {
if (logger.isDebugEnabled())
logger.debug("No navigation configuration found for node");
navigate(context, fromAction, outcome);
}
// reset the dispatch context
((NavigationBean) context.getExternalContext().getSessionMap().get(NavigationBean.BEAN_NAME)).resetDispatchContext();
} else {
if (logger.isDebugEnabled())
logger.debug("No dispatch context found");
// pass off to the original handler
navigate(context, fromAction, outcome);
}
}
Aggregations