use of org.alfresco.web.bean.generator.IComponentGenerator in project acs-community-packaging by Alfresco.
the class FacesHelper method getComponentGenerator.
/**
* Retrieves the named component generator implementation.
* If the named generator is not found the TextFieldGenerator is looked up
* as a default, if this is also not found an AlfrescoRuntimeException is thrown.
*
* @param context FacesContext
* @param generatorName The name of the component generator to retrieve
* @return The component generator instance
*/
public static IComponentGenerator getComponentGenerator(FacesContext context, String generatorName) {
IComponentGenerator generator = lookupComponentGenerator(context, generatorName);
if (generator == null) {
// create a text field if we can't find a component generator (a warning should have already been
// displayed on the appserver console)
logger.warn("Attempting to find default component generator '" + RepoConstants.GENERATOR_TEXT_FIELD + "'");
generator = lookupComponentGenerator(context, RepoConstants.GENERATOR_TEXT_FIELD);
}
// if we still don't have a component generator we should abort as vital configuration is missing
if (generator == null) {
throw new AlfrescoRuntimeException("Failed to find a component generator, please ensure the '" + RepoConstants.GENERATOR_TEXT_FIELD + "' bean is present in your configuration");
}
return generator;
}
use of org.alfresco.web.bean.generator.IComponentGenerator in project acs-community-packaging by Alfresco.
the class FacesHelper method lookupComponentGenerator.
private static IComponentGenerator lookupComponentGenerator(FacesContext context, String generatorName) {
IComponentGenerator generator = null;
Object obj = FacesHelper.getManagedBean(context, generatorName);
if (obj != null) {
if (obj instanceof IComponentGenerator) {
generator = (IComponentGenerator) obj;
if (logger.isDebugEnabled())
logger.debug("Found component generator for '" + generatorName + "': " + generator);
} else {
logger.warn("Bean '" + generatorName + "' does not implement IComponentGenerator");
}
} else {
logger.warn("Failed to find component generator with name of '" + generatorName + "'");
}
return generator;
}
Aggregations