use of org.springframework.extensions.config.ConfigLookupContext in project acs-community-packaging by Alfresco.
the class UIPropertySheet method encodeBegin.
/**
* @see javax.faces.component.UIComponent#encodeBegin(javax.faces.context.FacesContext)
*/
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
int howManyChildren = getChildren().size();
Boolean externalConfig = (Boolean) getAttributes().get("externalConfig");
// generate a variable name to use if necessary
if (this.variable == null) {
this.variable = DEFAULT_VAR_NAME;
}
// force retrieval of node info
Node node = getNode();
if (howManyChildren == 0) {
if (externalConfig != null && externalConfig.booleanValue()) {
// configure the component using the config service
if (logger.isDebugEnabled())
logger.debug("Configuring property sheet using ConfigService");
// get the properties to display
ConfigService configSvc = Application.getConfigService(FacesContext.getCurrentInstance());
Config configProps = null;
if (getConfigArea() == null) {
configProps = configSvc.getConfig(node);
} else {
// only look within the given area
configProps = configSvc.getConfig(node, new ConfigLookupContext(getConfigArea()));
}
PropertySheetConfigElement itemsToDisplay = (PropertySheetConfigElement) configProps.getConfigElement("property-sheet");
if (itemsToDisplay != null) {
Collection<ItemConfig> itemsToRender = null;
if (this.getMode().equalsIgnoreCase(EDIT_MODE)) {
itemsToRender = itemsToDisplay.getEditableItemsToShow().values();
if (logger.isDebugEnabled())
logger.debug("Items to render: " + itemsToDisplay.getEditableItemNamesToShow());
} else {
itemsToRender = itemsToDisplay.getItemsToShow().values();
if (logger.isDebugEnabled())
logger.debug("Items to render: " + itemsToDisplay.getItemNamesToShow());
}
createComponentsFromConfig(context, itemsToRender);
} else {
if (logger.isDebugEnabled())
logger.debug("There are no items to render!");
}
} else {
// show all the properties for the current node
if (logger.isDebugEnabled())
logger.debug("Configuring property sheet using node's current state");
createComponentsFromNode(context, node);
}
}
// put the node in the session if it is not there already
Map sessionMap = getFacesContext().getExternalContext().getSessionMap();
sessionMap.put(this.variable, node);
if (logger.isDebugEnabled())
logger.debug("Put node into session with key '" + this.variable + "': " + node);
super.encodeBegin(context);
}
Aggregations