in tapestry-framework/src/org/apache/tapestry/pageload/PageLoader.java [447:543]
private void constructComponent(
IRequestCycle cycle,
IPage page,
IComponent container,
IComponentSpecification containerSpec,
INamespace namespace)
{
_depth++;
if (_depth > _maxDepth)
_maxDepth = _depth;
List ids = new ArrayList(containerSpec.getComponentIds());
int count = ids.size();
try
{
for (int i = 0; i < count; i++)
{
String id = (String) ids.get(i);
// Get the sub-component specification from the
// container's specification.
IContainedComponent contained = containerSpec.getComponent(id);
String type = contained.getType();
ILocation location = contained.getLocation();
_componentResolver.resolve(cycle, namespace, type, location);
IComponentSpecification componentSpecification =
_componentResolver.getSpecification();
INamespace componentNamespace = _componentResolver.getNamespace();
// Instantiate the contained component.
IComponent component =
instantiateComponent(
page,
container,
id,
componentSpecification,
componentNamespace,
location);
// Add it, by name, to the container.
container.addComponent(component);
// Set up any bindings in the IContainedComponent specification
bind(container, component, contained);
// Now construct the component recusively; it gets its chance
// to create its subcomponents and set their bindings.
constructComponent(
cycle,
page,
component,
componentSpecification,
componentNamespace);
}
addAssets(container, containerSpec);
// Finish the load of the component; most components (which
// subclass BaseComponent) load their templates here.
// That may cause yet more components to be created, and more
// bindings to be set, so we defer some checking until
// later.
container.finishLoad(cycle, this, containerSpec);
// Finally, we create an initializer for each
// specified property.
createPropertyInitializers(page, container, containerSpec);
}
catch (ApplicationRuntimeException ex)
{
throw ex;
}
catch (RuntimeException ex)
{
throw new ApplicationRuntimeException(
Tapestry.format(
"PageLoader.unable-to-instantiate-component",
container.getExtendedId(),
ex.getMessage()),
container,
null,
ex);
}
_depth--;
}