// use the application defined in the FacesContext as we may be calling
// overriden methods
Application app = context.getApplication();
ViewDeclarationLanguage pdl = app.getViewHandler().getViewDeclarationLanguage(context, context.getViewRoot().getViewId());
BeanInfo componentMetadata = pdl.getComponentMetadata(context,
componentResource);
if (null != componentMetadata){
BeanDescriptor componentBeanDescriptor = componentMetadata.getBeanDescriptor();
// Step 1. See if the composite component author explicitly
// gave a componentType as part of the composite component metadata
ValueExpression ve = (ValueExpression)
componentBeanDescriptor.getValue(UIComponent.COMPOSITE_COMPONENT_TYPE_KEY);
if (null != ve) {
String componentType = (String) ve.getValue(context.getELContext());
if (null != componentType && 0 < componentType.length()) {
result = app.createComponent(componentType);
}
}
}
// Step 2. If that didn't work, if a script based resource can be
// found for the scriptComponentResource,
// see if a component can be generated from it
if (null == result) {
Resource scriptComponentResource = pdl.getScriptComponentResource(context, componentResource);
if (null != scriptComponentResource) {
result = createComponentFromScriptResource(context,
scriptComponentResource, componentResource);
}