One of the benefits to the new architecture in Tapestry 5 is that inserting standard or custom components into a page has become a lot simpler.
For example to insert a field called "title" that is stored in an object called webItemData used to require the following code:
<span jwcid="@Insert" value="ognl:webItemData.title">Item Summary</span>
The text "Item Summary" would get replaced by the contents of the "title" property. You could also define it using xml in your .jwc or .page file and do without the "ognl" entry, but that was even more typing. Essentially you would be defining the property two times, in the class, and in xml.
In T5 all you need to insert this same property is this:
${webItemData.title}
The property is only defined in the java class, and you only need to make sure the class is instantiated in your page or component class. I'm finding that most of the work I need to do in conversion involves deleting excess code.
There is a downside. I can see that it is harder to get useful previewable templates. Go to JumpStart (or search for Tapestry Jumpstart and click on Demo if this link breaks). Here you will find a discussion of invisible instrumentation (can we just call it "aye-aye" or something?). It helps with previewability, a little bit.
Nobody comes right out and says you should always use this invisible instrumentation, but I think it'd be foolish not too. Even if in some cases it doesn't help previews, it will always make the template easier to read for someone who knows html.
Monday, April 5, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment