Search in sources :

Example 1 with ActionsConfigElement

use of org.alfresco.web.config.ActionsConfigElement in project acs-community-packaging by Alfresco.

the class UIActions method encodeBegin.

/**
 * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
 */
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
    if (isRendered() == false) {
        return;
    }
    if (logger.isDebugEnabled())
        logger.debug("encodeBegin() for <r:actions/> Id: " + getId() + " groupId: " + getValue());
    // put the context object into the requestMap so it is accessable
    // by any child component value binding expressions
    Object actionContext = getContext();
    Map requestMap = getFacesContext().getExternalContext().getRequestMap();
    requestMap.put(ACTION_CONTEXT, actionContext);
    String contextId;
    if (actionContext instanceof Node) {
        contextId = ((Node) actionContext).getType().toString();
        if (this.groups.contains(contextId)) {
            if (logger.isDebugEnabled())
                logger.debug("---already built component tree for actions contextId: " + contextId);
            return;
        }
    } else {
        contextId = CONTEXTID_DEFAULT;
        if (this.groups.contains(contextId)) {
            if (logger.isDebugEnabled())
                logger.debug("---already built component tree for default actions.");
            return;
        }
    }
    // this will need removing from the child component set to ensure that it does not grow endlessly
    for (Iterator i = getChildren().iterator(); i.hasNext(); ) /**/
    {
        UIComponent child = (UIComponent) i.next();
        if (contextId.equals(child.getAttributes().get("contextId"))) {
            if (logger.isDebugEnabled())
                logger.debug("***removing old child component set for contextId: " + contextId);
            i.remove();
            break;
        }
    }
    String groupId = getValue();
    if (groupId != null && groupId.length() != 0) {
        Config config;
        if (actionContext instanceof Node) {
            config = Application.getConfigService(context).getConfig(actionContext);
        } else {
            config = Application.getConfigService(context).getGlobalConfig();
        }
        if (config != null) {
            // find the Actions specific config element
            ActionsConfigElement actionConfig = (ActionsConfigElement) config.getConfigElement(ActionsConfigElement.CONFIG_ELEMENT_ID);
            if (actionConfig != null) {
                // and lookup our ActionGroup by Id
                ActionGroup actionGroup = actionConfig.getActionGroup(groupId);
                if (actionGroup != null) {
                    // render the action group component tree
                    if (logger.isDebugEnabled())
                        logger.debug("-constructing ActionGroup: " + groupId + " for ContextId: " + contextId);
                    buildActionGroup(context, actionConfig, actionGroup, contextId);
                } else {
                    logger.warn("Unable to find specified Action Group config ID: " + groupId);
                }
            }
        }
    }
}
Also used : ActionsConfigElement(org.alfresco.web.config.ActionsConfigElement) ActionGroup(org.alfresco.web.config.ActionsConfigElement.ActionGroup) Config(org.springframework.extensions.config.Config) Node(org.alfresco.web.bean.repository.Node) Iterator(java.util.Iterator) UIComponent(javax.faces.component.UIComponent) Map(java.util.Map)

Aggregations

Iterator (java.util.Iterator)1 Map (java.util.Map)1 UIComponent (javax.faces.component.UIComponent)1 Node (org.alfresco.web.bean.repository.Node)1 ActionsConfigElement (org.alfresco.web.config.ActionsConfigElement)1 ActionGroup (org.alfresco.web.config.ActionsConfigElement.ActionGroup)1 Config (org.springframework.extensions.config.Config)1