use of org.alfresco.web.config.PropertySheetConfigElement 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);
}
use of org.alfresco.web.config.PropertySheetConfigElement in project acs-community-packaging by Alfresco.
the class DocumentPropertiesDialog method getOtherPropertiesPresent.
/**
* Determines whether this document has any other properties other than the
* default set to display to the user.
*
* @return true of there are properties to show, false otherwise
*/
public boolean getOtherPropertiesPresent() {
if ((this.hasOtherProperties == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
// we need to use the config service to see whether there are any
// editable properties configured for this document.
ConfigService configSvc = Application.getConfigService(FacesContext.getCurrentInstance());
Config configProps = configSvc.getConfig(this.editableNode);
PropertySheetConfigElement propsToDisplay = (PropertySheetConfigElement) configProps.getConfigElement("property-sheet");
if (propsToDisplay != null && propsToDisplay.getEditableItemNamesToShow().size() > 0) {
this.hasOtherProperties = Boolean.TRUE;
} else {
this.hasOtherProperties = Boolean.FALSE;
}
}
return this.hasOtherProperties.booleanValue();
}
Aggregations