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);
}
}
}
}
}
Aggregations