In Tapestry 4 and earlier, there was a kind of ambiguity about what a "component" or "page" was. This screwed over Geoff in terms of Spindle for T4, and generally made even the simplest discussion of where to put what files a chore.
For T5, components are classes. Pages are a special flavor of components, and also a class. The case-insensitive, logical, short name for a page is mapped directly to a fully qualified class name as early as possible. Templates and other resources are associated with the class. The scan to find all the known pages and components (happens at startup, and necessary for case-insentivity) is based on locating the class files. It is exceedingly rare to have a component that truly has no logic, no properties, no methods in it. As soon as you add a parameter, you'll need a Java class for the @Parameter annotation (on a field). So we've optimized for a very simple rule system (simple relative to T4) to define what pages, components and mixins are available and where. The expense is that you may need to create an empty Java class. That's fine ... it probably won't stay empty for long. If we bent the system to allow for codeless components, it complicates the mental model of what Tapestry does and ushers back in the steep learning curve. In the long run, it is better to tell users "create an empty class always" then it is to say "decide if you want a class or not, etc., etc., etc.". Decisions are bad. Make fewer decisions. On 5/25/07, Jessica Sobieski <[EMAIL PROTECTED]> wrote:
Thank you Howard, that did it. I had Layout.html in WEB-INF as you pointed out. I just have a follow up question, from a perspective of someone totally new to this. If I don't need any dynamic content in my layout, why do I need to create a java class for it? That is, if I just place Layout.html in components package, Tapestry is complaining until I create Layout.java to go with it, even that the class is nothing but empty? On 5/25/07, Howard Lewis Ship <[EMAIL PROTECTED]> wrote: > > Component templates are not allowed in WEB-INF, they must go on the > classpath, in the same package/folder as the Java class. The Layout > component is rendering, but does nothing and the default behavior is to > render its boyd, thus you see the "this is a test page" text. > > On 5/25/07, Jessica Sobieski <[EMAIL PROTECTED]> wrote: > > > > Hi Everyone. > > > > I'm new to Tapestry and I'm trying to build my first application. I want > > to > > have a common layout with few simple pages and I've read up about the > > "Layout" component, but I'm not exactly sure how to use it. I did the > > following: > > > > Layout.html > > <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> > > <head> > > <title>My Tapestry Application</title> > > </head> > > <body> > > Static text. > > <p/> > > <t:body/> > > </body> > > </html> > > > > components.Layout.java > > public class Layout { > > } > > > > > > Start.html > > <t:layout id="layout" xmlns:t=" > > http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> > > <b>This is a test page.</b> > > </t:layout> > > > > Yet, I'm not seeing the layout. What am I missing? > > > > Thanks - Jess > > > > > > -- > Howard M. Lewis Ship > TWD Consulting, Inc. > Independent J2EE / Open-Source Java Consultant > Creator and PMC Chair, Apache Tapestry > Creator, Apache HiveMind > > Professional Tapestry training, mentoring, support > and project work. http://howardlewisship.com >
-- Howard M. Lewis Ship TWD Consulting, Inc. Independent J2EE / Open-Source Java Consultant Creator and PMC Chair, Apache Tapestry Creator, Apache HiveMind Professional Tapestry training, mentoring, support and project work. http://howardlewisship.com