Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: scrollbar
{
Div
Wiki Markup
style
float:right
titleRelated Articles
classaui-label
Content by Label
showLabelsfalse
showSpacefalse
titleRelated Articles
cqllabel in ("component-templates","component-classes") and space = currentSpace()
|background=#eee} {contentbylabel:title=Related Articles|showLabels=false|showSpace=false|space=@self|labels=component-templates,component-classes} {float}

You'll see frequent reference to a Layout Component in Tapestry documentation, but you won't find such a component in the component reference. The Layout component is a component that you create to provide common elements across all of your pages.

...

We use the @Import annotation (in 5.2 or later), as opposed to directly adding the <link> element to the template, for significant performance benefits described elsewhere. (For 5.0 and 5.1, use the deprecated @IncludeStyleSheet @IncludeStyleSheet annotation instead.)

You may find that your application has more than one look and feel: perhaps user registration pages have one look, while administrative pages have another. This can be accomplished by having multiple layout components (using any names you choose) and using those different layout types for different pages.

...

Code Block
languagexml
titleLayout.tml (a template for a Layout component)
<!DOCTYPE html>
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd">
    <head>
        <meta charset="UTF-8" />
        <title>${title} - NiftyWebCo, Inc</title>
        <style type="text/css">
            <t:delegate to="style" />
        </style>
    </head>
    <body>
        <div class="nav-top">
            Nifty Web Application
        </div>

        <h1>${title}</h1>

        <t:alerts/>
   
        <t:body/>

        <div class="nav-bottom">
            (C) 2012 NiftyWebCo, Inc.
        </div>
    </body>
</html>

The Alerts component above is new in (Tapestry 5.3 ; it and later) allows the application to present alert messages to the client in a consistent way. If you want alerts to always appear in the banner of your web site, it may make sense to put it in the layout component's template, as above.

...

Code Block
languagexml
titleUserList.tml
<html t:type="layout" title="List of Users"
    xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"
    xmlns:p="tapestry:parameter">
<p:style>
    TD.profile { background: url('${backgroundImageuserPhoto}') }
</p:style>

<div>
    Imagine a table of user account information here.
</div>

</html>

...

The rendered HTML would look like the following (whitespace aside, and assuming UserList.java has a backgroundImage property whose value is the string "http://www.example.com/fuzzy.gif"):

Code Block
languagexml
titleThe rendered HTML
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>List of Users - NiftyWebCo, Inc</title>
        <style type="text/css">
            TD.profile { background: url('http://www.example.com/fuzzy.gif') }
        </style>
    </head>
    <body>
        <div class="nav-top">
            Nifty Web Application
        </div>

        <h1>List of Users</h1>

        <div id="alerts"></div>

        <div>
            Imagine a table of user account information here.
        </div>

        <div class="nav-bottom">
            (C) 2012 NiftyWebCo, Inc.
        </div>
    </body>
</html>
 

Scrollbar