[Tapestry-commits] CVS: Tapestry/framework/src/net/sf/tapestry/pageload PageLoader.java,1.15,1.15.2.
Brought to you by:
hship
|
From: Howard L. S. <hs...@us...> - 2002-11-30 03:33:23
|
Update of /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/pageload
In directory sc8-pr-cvs1:/tmp/cvs-serv15444/framework/src/net/sf/tapestry/pageload
Modified Files:
Tag: hship-2-3
PageLoader.java
Log Message:
Add support for providing expressions in component templates.
Index: PageLoader.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/pageload/PageLoader.java,v
retrieving revision 1.15
retrieving revision 1.15.2.1
diff -C2 -d -r1.15 -r1.15.2.1
*** PageLoader.java 27 Nov 2002 17:58:55 -0000 1.15
--- PageLoader.java 30 Nov 2002 03:33:20 -0000 1.15.2.1
***************
*** 2,5 ****
--- 2,6 ----
import java.util.ArrayList;
+ import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
***************
*** 91,95 ****
// For compatibility with the 1.1 and 1.2 specifications, which allow
// the component type to be a complete specification path.
!
if (alias.startsWith("/"))
{
--- 92,96 ----
// For compatibility with the 1.1 and 1.2 specifications, which allow
// the component type to be a complete specification path.
!
if (alias.startsWith("/"))
{
***************
*** 206,211 ****
component.setBinding(name, binding);
}
! i = spec.getParameterNames().iterator();
while (i.hasNext())
--- 207,227 ----
component.setBinding(name, binding);
}
+ }
! /**
! * Invoked from {@link #loadPage(String, INamespace, IRequestCycle, ComponentSpecification)}
! * after the entire tree of components in the page has been constructed. Recursively
! * checks each component in the tree to ensure that
! * all of its required parameters are bound.
! *
! * @since NEXT_RELEASE
! *
! **/
!
! private void verifyRequiredParameters(IComponent component) throws PageLoaderException
! {
! ComponentSpecification spec = component.getSpecification();
!
! Iterator i = spec.getParameterNames().iterator();
while (i.hasNext())
***************
*** 220,223 ****
--- 236,253 ----
null);
}
+
+ Collection components = component.getComponents().values();
+
+ if (Tapestry.size(components) == 0)
+ return;
+
+ i = components.iterator();
+
+ while (i.hasNext())
+ {
+ IComponent embedded = (IComponent) i.next();
+
+ verifyRequiredParameters(embedded);
+ }
}
***************
*** 271,275 ****
* <li>Setting up bindings between container and containees.
* <li>Construct the containees recursively.
! * <li>Telling the component its 'ready' (so that it can load its HTML template)
* </ul>
*
--- 301,305 ----
* <li>Setting up bindings between container and containees.
* <li>Construct the containees recursively.
! * <li>Invoking {@link IComponent#finishLoad(IRequestCycle, IPageLoader, ComponentSpecification)}
* </ul>
*
***************
*** 296,299 ****
--- 326,330 ----
List ids = new ArrayList(containerSpec.getComponentIds());
int count = ids.size();
+ Map propertyBindings = new HashMap();
for (int i = 0; i < count; i++)
***************
*** 317,326 ****
instantiateComponent(page, container, id, componentSpecification, componentNamespace);
! // Add it, by name, to the container.
container.addComponent(component);
! // Recursively construct the component
constructComponent(cycle, page, component, componentSpecification, componentNamespace);
}
--- 348,362 ----
instantiateComponent(page, container, id, componentSpecification, componentNamespace);
! // Add it, by name, to the container.
container.addComponent(component);
! // Set up any bindings in the ContainedComponent specification
+ bind(container, component, contained, propertyBindings);
+
+ // Now construct the component recusively; it gets its chance
+ // to create its subcomponents and set their bindings.
+
constructComponent(cycle, page, component, componentSpecification, componentNamespace);
}
***************
*** 328,331 ****
--- 364,373 ----
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);
***************
*** 473,477 ****
constructComponent(cycle, page, page, specification, namespace);
! setBindings(page);
}
finally
--- 515,519 ----
constructComponent(cycle, page, page, specification, namespace);
! verifyRequiredParameters(page);
}
finally
***************
*** 487,524 ****
return page;
- }
-
- /**
- * Sets all bindings, top-down. Checking (as it goes) that all required parameters
- * have been set.
- *
- * @since 1.0.6
- *
- **/
-
- private void setBindings(IComponent container) throws PageLoaderException
- {
- Map components = container.getComponents();
-
- if (components.isEmpty())
- return;
-
- ComponentSpecification containerSpec = container.getSpecification();
-
- Map propertyBindings = new HashMap();
-
- Iterator i = components.entrySet().iterator();
- while (i.hasNext())
- {
- Map.Entry e = (Map.Entry) i.next();
- String id = (String) e.getKey();
- IComponent component = (IComponent) e.getValue();
- ComponentSpecification spec = component.getSpecification();
- ContainedComponent contained = containerSpec.getComponent(id);
-
- bind(container, component, contained, propertyBindings);
-
- setBindings(component);
- }
}
--- 529,532 ----
|