JDK 1.5 will be an issue for many, for sure. I like the example....however....Howard Ship mentioned once that he planned to hide all code that facilitated just such an example (correct me if I'm wrong), thus nixing any non-Block-oriented dynamic component creation. If that is indeed true, then it seems that any Tapestry 3 library I create for just such a mechansim would be invalid in Tapestry 4.
Would this example work in Tapestry 4? If not, how would it be done? Thanks, - Mike "Mark Stang" <[EMAIL PROTECTED]> 03/23/2006 12:02 PM Please respond to "Tapestry users" <[email protected]> To "Tapestry users" <[email protected]>, "Tapestry users" <[email protected]> cc Subject Dynamically creating components at runtime All, This is a 3.x mechanism for dynamically creating components at runtime. I am posting it for two reasons, one is to provide a mechanism for other developers. The second is so that people can review the implementation and point out any "concerns". @SuppressWarnings("unchecked") private <T> T newComponent(String componentName, Class<T> baseClass, IRequestCycle cycle) { ComponentSpecificationResolver resolver = new ComponentSpecificationResolver(cycle); resolver.resolve(cycle, cycle.getPage().getNamespace(), null, componentName, null); IComponentSpecification spec = resolver.getSpecification(); IEngine engine = cycle.getEngine(); Class c =engine.getComponentClassEnhancer().getEnhancedClass(spec,baseClass.getName()); try { IComponent result = (IComponent)c.newInstance(); result.setSpecification(spec); result.setPage(cycle.getPage()); result.setContainer(this); return (T)result; } catch (Exception e) { // Toss any instantiation exceptions up the stack; there's nothing to be done throw new RuntimeException(e); } } Thoughts? thanks, Mark
