Search in sources :

Example 1 with NavigationConfigElement

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);
    }
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) NavigationBean(org.alfresco.web.bean.NavigationBean) WizardConfig(org.alfresco.web.config.WizardsConfigElement.WizardConfig) DialogConfig(org.alfresco.web.config.DialogsConfigElement.DialogConfig) Config(org.springframework.extensions.config.Config) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) NavigationResult(org.alfresco.web.config.NavigationResult) NavigationConfigElement(org.alfresco.web.config.NavigationConfigElement)

Aggregations

InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)1 NavigationBean (org.alfresco.web.bean.NavigationBean)1 DialogConfig (org.alfresco.web.config.DialogsConfigElement.DialogConfig)1 NavigationConfigElement (org.alfresco.web.config.NavigationConfigElement)1 NavigationResult (org.alfresco.web.config.NavigationResult)1 WizardConfig (org.alfresco.web.config.WizardsConfigElement.WizardConfig)1 Config (org.springframework.extensions.config.Config)1 ConfigService (org.springframework.extensions.config.ConfigService)1