Modified: websites/production/tapestry/content/css.html ============================================================================== --- websites/production/tapestry/content/css.html (original) +++ websites/production/tapestry/content/css.html Sat Jan 18 18:21:05 2014 @@ -29,6 +29,7 @@ <link href='http://cxf.apache.org/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet' type='text/css' /> <script src='http://cxf.apache.org/resources/highlighter/scripts/shCore.js' type='text/javascript'></script> <script src='http://cxf.apache.org/resources/highlighter/scripts/shBrushJava.js' type='text/javascript'></script> + <script src='http://cxf.apache.org/resources/highlighter/scripts/shBrushXml.js' type='text/javascript'></script> <script type="text/javascript"> SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); @@ -69,16 +70,14 @@ </div> <div id="content"> -<div id="ConfluenceContent"><h1 id="CSS-CascadingStyleSheets">Cascading Style Sheets</h1> - -<div class="navmenu" style="float:right; background:#eee; margin:3px; padding:3px"> +<div id="ConfluenceContent"><h1 id="CSS-CascadingStyleSheets">Cascading Style Sheets</h1><div class="navmenu" style="float:right; background:#eee; margin:3px; padding:3px"> <h3>Related Articles</h3> <ul class="content-by-label"><li> <div> <span class="icon icon-page" title="Page">Page:</span> </div> <div class="details"> - <a shape="rect" href="css.html">CSS</a> + <a shape="rect" href="layout-component.html">Layout Component</a> </div> @@ -87,7 +86,7 @@ <span class="icon icon-page" title="Page">Page:</span> </div> <div class="details"> - <a shape="rect" href="layout-component.html">Layout Component</a> + <a shape="rect" href="javascript.html">JavaScript</a> </div> @@ -96,7 +95,7 @@ <span class="icon icon-page" title="Page">Page:</span> </div> <div class="details"> - <a shape="rect" href="javascript.html">JavaScript</a> + <a shape="rect" href="css.html">CSS</a> </div> @@ -110,67 +109,25 @@ </div> </li></ul> -</div> - -<p>Most web applications delegate to <strong>Cascading Style Sheets</strong> (CSS) the stylistic details of the page – fonts, colors, margins, borders and alignment. This helps the remaining HTML to remain simple and semantic, which usually makes it easier to read and maintain.</p> - -<p>Tapestry includes sophisticated support for CSS in the form of annotation-based linking, far-future expire headers, automatic duplicate removal, and other features provided for <a shape="rect" href="assets.html">assets</a>.</p> - -<h2 id="CSS-Defaultstylesheet">Default style sheet</h2> - -<p>Tapestry includes a built-in style sheet, default.css, in all HTML documents (documents that have an outer <html> element and a nested <head> element). The default.css style sheet is always ordered <em>first</em> ... any additional style sheets will come after. This allows you to override Tapestry's default styles with your own.</p> - -<p>All the styles in the default style sheet are prefixed with "t-" (for Tapestry).</p> - -<h2 id="CSS-AddingyourownCSS">Adding your own CSS</h2> - -<p>A page or component (for example, a <a shape="rect" href="layout-component.html">layout component</a>) that is rendering the <head> tag can add a style sheet directly in the markup.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -<head> +</div><p>Most web applications delegate to <strong>Cascading Style Sheets</strong> (CSS) the stylistic details of the page – fonts, colors, margins, borders and alignment. This helps the remaining HTML to remain simple and semantic, which usually makes it easier to read and maintain.</p><p>Tapestry includes sophisticated support for CSS in the form of annotation-based linking, far-future expire headers, automatic duplicate removal, and other features provided for <a shape="rect" href="assets.html">assets</a>.</p><h2 id="CSS-Defaultstylesheet">Default style sheet</h2><p>Tapestry includes a built-in style sheet, default.css, in all HTML documents (documents that have an outer <html> element and a nested <head> element). The default.css style sheet is always ordered <em>first</em> ... any additional style sheets will come after. This allows you to override Tapestry's default styles with your own.</p><p>All the styles in the default style sheet are prefixed with "t-" ( for Tapestry).</p><h2 id="CSS-AddingyourownCSS">Adding your own CSS</h2><p>A page or component (for example, a <a shape="rect" href="layout-component.html">layout component</a>) that is rendering the <head> tag can add a style sheet directly in the markup.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[<head> <link href="/css/site.css" rel="stylesheet" type="text/css"/> . . . ]]></script> -</div></div> - -<p>If you want to leverage Tapestry's localization support, you may want to make use of an expansion and the "asset:" or "context:" binding prefix:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -<head> +</div></div><p>If you want to leverage Tapestry's localization support, you may want to make use of an expansion and the "asset:" or "context:" binding prefix:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[<head> <link href="${context:css/site.css}" rel="stylesheet" type="text/css"/> . . . ]]></script> -</div></div> - -<p>The "context:" prefix means that the remainder of the expansion is a path to a context asset, a resource in the web application root (src/main/webapp in your workspace). By contrast, the "asset:" prefix tells Tapestry to look in the class path. See <a shape="rect" href="assets.html">Assets</a>.</p> - -<h2 id="CSS-Usingthe@Importannotation">Using the @Import annotation</h2> - -<p>Another approach to adding a style sheet is to include an @<a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Import.html">Import</a> annotation (starting with Tapestry 5.2) on your component class:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -@Import(stylesheet="context:css/site.css") +</div></div><p>The "context:" prefix means that the remainder of the expansion is a path to a context asset, a resource in the web application root (src/main/webapp in your workspace). By contrast, the "asset:" prefix tells Tapestry to look in the class path. See <a shape="rect" href="assets.html">Assets</a>.</p><h2 id="CSS-Usingthe@Importannotation">Using the @Import annotation</h2><p>Another approach to adding a style sheet is to include an @<a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Import.html">Import</a> annotation (starting with Tapestry 5.2) on your component class:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Import(stylesheet="context:css/site.css") public class MyComponent { } ]]></script> -</div></div> - -<p>(For Tapestry 5.0 and 5.1, use the deprecated <a shape="rect" class="external-link" href="http://tapestry.apache.org/5.2/apidocs/org/apache/tapestry5/annotations/IncludeStylesheet.html">@IncludeStyleSheet</a> annotation instead.)</p> - -<p>As with <a shape="rect" href="javascript.html">included JavaScript libraries</a>, each style sheet will only be added once, regardless of the number of components that include it via the annotation.</p> - -<h2 id="CSS-ConditionallyloadingIE-onlystylesheets">Conditionally loading IE-only style sheets</h2> - -<p>For Tapestry 5.2 and later, if you need to load a different style sheet for Internet Explorer browsers, or for certain versions of IE browsers, you can use Tapestry's built-in support for IE conditional comments. Just add something like the following to your page or component (or layout) class:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -@Environmental +</div></div><p>(For Tapestry 5.0 and 5.1, use the deprecated <a shape="rect" class="external-link" href="http://tapestry.apache.org/5.2/apidocs/org/apache/tapestry5/annotations/IncludeStylesheet.html">@IncludeStyleSheet</a> annotation instead.)</p><p>As with <a shape="rect" href="javascript.html">included JavaScript libraries</a>, each style sheet will only be added once, regardless of the number of components that include it via the annotation.</p><h2 id="CSS-ConditionallyloadingIE-onlystylesheets">Conditionally loading IE-only style sheets</h2><p>For Tapestry 5.2 and later, if you need to load a different style sheet for Internet Explorer browsers, or for certain versions of IE browsers, you can use Tapestry's built-in support for IE conditional comments. Just add something like the following to your page or component (or layout) class:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Environmental private JavaScriptSupport javaScriptSupport; @Inject @Path("context:layout/ie-only.css") @@ -182,34 +139,19 @@ void afterRender() { StylesheetOptions(null, "IE")) ); } ]]></script> -</div></div> - -<p>The above will render something like:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ -<!--[if IE]> +</div></div><p>The above will render something like:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<!--[if IE]> <link type="text/css" rel="stylesheet" href="/assets/1.0-SNAPSHOT/ctx/layout/ie-only.css"></link> <![endif]--> ]]></script> -</div></div> - -<p>Naturally, the conditional part can be any other IE <a shape="rect" class="external-link" href="http://en.wikipedia.org/wiki/Conditional_comment" >conditional expression</a>, such as "lt IE 8".</p> - -<h2 id="CSS-Suppressingthedefaultstylesheet">Suppressing the default style sheet</h2> - -<p>Though it should be rarely needed, you can prevent Tapestry's default style sheet from loading by overriding the configuration in your application's module (normally AppModule.java):</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>AppModule.java (partial)</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -@Contribute(MarkupRenderer.class) +</div></div><p>Naturally, the conditional part can be any other IE <a shape="rect" class="external-link" href="http://en.wikipedia.org/wiki/Conditional_comment" >conditional expression</a>, such as "lt IE 8".</p><h2 id="CSS-Suppressingthedefaultstylesheet">Suppressing the default style sheet</h2><p>Though it should be rarely needed, you can prevent Tapestry's default style sheet from loading by overriding the configuration in your application's module (normally AppModule.java):</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>AppModule.java (partial)</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Contribute(MarkupRenderer.class) public static void deactiveDefaultCSS(OrderedConfiguration<MarkupRendererFilter> configuration) { configuration.override("InjectDefaultStyleheet", null); } ]]></script> -</div></div> -<p>Note: In Tapestry 5.3 and later, the misspelled "InjectDefaultStyleheet" is corrected to "InjectDefaultStylesheet".</p></div> +</div></div><p>Note: In Tapestry 5.3 and later, the misspelled "InjectDefaultStyleheet" is corrected to "InjectDefaultStylesheet".</p></div> </div> <div class="clearer"></div>
Modified: websites/production/tapestry/content/default-parameter.html ============================================================================== --- websites/production/tapestry/content/default-parameter.html (original) +++ websites/production/tapestry/content/default-parameter.html Sat Jan 18 18:21:05 2014 @@ -29,6 +29,7 @@ <link href='http://cxf.apache.org/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet' type='text/css' /> <script src='http://cxf.apache.org/resources/highlighter/scripts/shCore.js' type='text/javascript'></script> <script src='http://cxf.apache.org/resources/highlighter/scripts/shBrushJava.js' type='text/javascript'></script> + <script src='http://cxf.apache.org/resources/highlighter/scripts/shBrushXml.js' type='text/javascript'></script> <script type="text/javascript"> SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); @@ -77,19 +78,14 @@ table.ScrollbarTable td.ScrollbarParent table.ScrollbarTable td.ScrollbarNextName {text-align: right;border: none;} table.ScrollbarTable td.ScrollbarNextIcon {text-align: center;width: 16px;border: none;} -/*]]>*/</style><div class="Scrollbar"><table class="ScrollbarTable"><tr><td colspan="1" rowspan="1" class="ScrollbarPrevName" width="33%"> </td><td colspan="1" rowspan="1" class="ScrollbarParent" width="33%"><sup><a shape="rect" href="cookbook.html"><img align="middle" border="0" src="https://cwiki.apache.org/confluence/images/icons/up_16.gif" width="8" height="8"></a></sup><a shape="rect" href="cookbook.html">Cookbook</a></td><td colspan="1" rowspan="1" class="ScrollbarNextName" width="33%"> <a shape="rect" href="overriding-exception-reporting.html">Overriding Exception Reporting</a></td><td colspan="1" rowspan="1" class="ScrollbarNextIcon"><a shape="rect" href="overriding-exception-reporting.html"><img align="middle" border="0" src="https://cwiki.apache.org/confluence/images/icons/forwd_16.gif" width="16" height="16"></a></td></tr></table></div> -<p></p> - -<h1 id="DefaultParameter-DefaultParameter">Default Parameter</h1> - -<div class="navmenu" style="float:right; background:#eee; margin:3px; padding:3px"> +/*]]>*/</style><div class="Scrollbar"><table class="ScrollbarTable"><tr><td colspan="1" rowspan="1" class="ScrollbarPrevName" width="33%"> </td><td colspan="1" rowspan="1" class="ScrollbarParent" width="33%"><sup><a shape="rect" href="cookbook.html"><img align="middle" border="0" src="https://cwiki.apache.org/confluence/images/icons/up_16.gif" width="8" height="8"></a></sup><a shape="rect" href="cookbook.html">Cookbook</a></td><td colspan="1" rowspan="1" class="ScrollbarNextName" width="33%"> <a shape="rect" href="overriding-exception-reporting.html">Overriding Exception Reporting</a></td><td colspan="1" rowspan="1" class="ScrollbarNextIcon"><a shape="rect" href="overriding-exception-reporting.html"><img align="middle" border="0" src="https://cwiki.apache.org/confluence/images/icons/forwd_16.gif" width="16" height="16"></a></td></tr></table></div><h1 id="DefaultParameter-DefaultParameter">Default Parameter</h1><div class="navmenu" style="float:right; background:#eee; margi n:3px; padding:3px"> <h3>Related Articles</h3> <ul class="content-by-label"><li> <div> <span class="icon icon-page" title="Page">Page:</span> </div> <div class="details"> - <a shape="rect" href="component-parameters.html">Component Parameters</a> + <a shape="rect" href="supporting-informal-parameters.html">Supporting Informal Parameters</a> </div> @@ -98,7 +94,7 @@ table.ScrollbarTable td.ScrollbarNextIco <span class="icon icon-page" title="Page">Page:</span> </div> <div class="details"> - <a shape="rect" href="default-parameter.html">Default Parameter</a> + <a shape="rect" href="enum-parameter-recipe.html">Enum Parameter Recipe</a> </div> @@ -107,7 +103,7 @@ table.ScrollbarTable td.ScrollbarNextIco <span class="icon icon-page" title="Page">Page:</span> </div> <div class="details"> - <a shape="rect" href="supporting-informal-parameters.html">Supporting Informal Parameters</a> + <a shape="rect" href="component-parameters.html">Component Parameters</a> </div> @@ -116,22 +112,13 @@ table.ScrollbarTable td.ScrollbarNextIco <span class="icon icon-page" title="Page">Page:</span> </div> <div class="details"> - <a shape="rect" href="enum-parameter-recipe.html">Enum Parameter Recipe</a> + <a shape="rect" href="default-parameter.html">Default Parameter</a> </div> </li></ul> -</div> - -<p>Many of the components provided with Tapestry share a common behavior: if the component's id matches a property of the container, then some parameter of the component (usually value) defaults to that property.</p> - -<p>This is desirable, in terms of not having to specify the component's id and then specify the same value as some other parameter.</p> - -<p>Let's say you have created a component, <code>RichTextEditor</code>, which operates like a normal TextArea component, but provides a JavaScript rich text editor. You might start with something like:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -public class RichTextEditor implements Field +</div><p>Many of the components provided with Tapestry share a common behavior: if the component's id matches a property of the container, then some parameter of the component (usually value) defaults to that property.</p><p>This is desirable, in terms of not having to specify the component's id and then specify the same value as some other parameter.</p><p>Let's say you have created a component, <code>RichTextEditor</code>, which operates like a normal TextArea component, but provides a JavaScript rich text editor. You might start with something like:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[public class RichTextEditor implements Field { @Property @Parameter(required=true) @@ -140,35 +127,17 @@ public class RichTextEditor implements F . . . // Lots more code not shown here } ]]></script> -</div></div> - -<p>However, the weakness here is when you make use of the component. You template may look like:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ - <t:label for="profile"/> +</div></div><p>However, the weakness here is when you make use of the component. You template may look like:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ <t:label for="profile"/> <br/> <t:richtexteditor t:id="profile" value="profile"/> ]]></script> -</div></div> - -<p>Every component has a unique id; if you don't assign one with the <code>t:id</code> attribute, Tapestry will assign a less meaningful one. Component ids can end up inside URLs or used as query parameter names, so using meaningful ids helps if you are ever stuck debugging a request.</p> - -<p>This repetition can be avoided by adding the <em>autoconnect</em> attribute to the @Parameter annotation:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ - @Property +</div></div><p>Every component has a unique id; if you don't assign one with the <code>t:id</code> attribute, Tapestry will assign a less meaningful one. Component ids can end up inside URLs or used as query parameter names, so using meaningful ids helps if you are ever stuck debugging a request.</p><p>This repetition can be avoided by adding the <em>autoconnect</em> attribute to the @Parameter annotation:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ @Property @Parameter(required=true, autoconnect=true) private String value; ]]></script> -</div></div> - -<p>This can now be written as <code><t:richtexteditor t:id="profile"/></code>. The unwanted repetition is gone: we set the id of the component and the property it edits in a single pass.</p> - -<p>If there is no matching property, then a runtime exception will be thrown when loading the page because the value parameter is required and not bound.</p> - -<p>The most common case of using autoconnect is form control components such as TextField and friends ... or this RichTextEditor.</p></div> +</div></div><p>This can now be written as <code><t:richtexteditor t:id="profile"/></code>. The unwanted repetition is gone: we set the id of the component and the property it edits in a single pass.</p><p>If there is no matching property, then a runtime exception will be thrown when loading the page because the value parameter is required and not bound.</p><p>The most common case of using autoconnect is form control components such as TextField and friends ... or this RichTextEditor.</p></div> </div> <div class="clearer"></div> Modified: websites/production/tapestry/content/error-page-recipe.html ============================================================================== --- websites/production/tapestry/content/error-page-recipe.html (original) +++ websites/production/tapestry/content/error-page-recipe.html Sat Jan 18 18:21:05 2014 @@ -29,6 +29,7 @@ <link href='http://cxf.apache.org/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet' type='text/css' /> <script src='http://cxf.apache.org/resources/highlighter/scripts/shCore.js' type='text/javascript'></script> <script src='http://cxf.apache.org/resources/highlighter/scripts/shBrushJava.js' type='text/javascript'></script> + <script src='http://cxf.apache.org/resources/highlighter/scripts/shBrushXml.js' type='text/javascript'></script> <script type="text/javascript"> SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); @@ -77,17 +78,14 @@ table.ScrollbarTable td.ScrollbarParent table.ScrollbarTable td.ScrollbarNextName {text-align: right;border: none;} table.ScrollbarTable td.ScrollbarNextIcon {text-align: center;width: 16px;border: none;} -/*]]>*/</style><div class="Scrollbar"><table class="ScrollbarTable"><tr><td colspan="1" rowspan="1" class="ScrollbarPrevIcon"><a shape="rect" href="enum-parameter-recipe.html"><img align="middle" border="0" src="https://cwiki.apache.org/confluence/images/icons/back_16.gif" width="16" height="16"></a></td><td colspan="1" rowspan="1" class="ScrollbarPrevName" width="33%"><a shape="rect" href="enum-parameter-recipe.html">Enum Parameter Recipe</a> </td><td colspan="1" rowspan="1" class="ScrollbarParent" width="33%"><sup><a shape="rect" href="cookbook.html"><img align="middle" border="0" src="https://cwiki.apache.org/confluence/images/icons/up_16.gif" width="8" height="8"></a></sup><a shape="rect" href="cookbook.html">Cookbook</a></td><td colspan="1" rowspan="1" class="ScrollbarNextName" width="33%"> <a shape="rect" href="extending-the-if-component.html">Extending the If Component</a></td><td colspan="1" rowspan="1" class="ScrollbarNextIcon"><a shape="rect" href="extending-the- if-component.html"><img align="middle" border="0" src="https://cwiki.apache.org/confluence/images/icons/forwd_16.gif" width="16" height="16"></a></td></tr></table></div> -<p></p> - -<div class="navmenu" style="float:right; background:#eee; margin:3px; padding:3px"> +/*]]>*/</style><div class="Scrollbar"><table class="ScrollbarTable"><tr><td colspan="1" rowspan="1" class="ScrollbarPrevIcon"><a shape="rect" href="enum-parameter-recipe.html"><img align="middle" border="0" src="https://cwiki.apache.org/confluence/images/icons/back_16.gif" width="16" height="16"></a></td><td colspan="1" rowspan="1" class="ScrollbarPrevName" width="33%"><a shape="rect" href="enum-parameter-recipe.html">Enum Parameter Recipe</a> </td><td colspan="1" rowspan="1" class="ScrollbarParent" width="33%"><sup><a shape="rect" href="cookbook.html"><img align="middle" border="0" src="https://cwiki.apache.org/confluence/images/icons/up_16.gif" width="8" height="8"></a></sup><a shape="rect" href="cookbook.html">Cookbook</a></td><td colspan="1" rowspan="1" class="ScrollbarNextName" width="33%"> <a shape="rect" href="extending-the-if-component.html">Extending the If Component</a></td><td colspan="1" rowspan="1" class="ScrollbarNextIcon"><a shape="rect" href="extending-the- if-component.html"><img align="middle" border="0" src="https://cwiki.apache.org/confluence/images/icons/forwd_16.gif" width="16" height="16"></a></td></tr></table></div><div class="navmenu" style="float:right; background:#eee; margin:3px; padding:3px"> <h3>Related Articles</h3> <ul class="content-by-label"><li> <div> <span class="icon icon-page" title="Page">Page:</span> </div> <div class="details"> - <a shape="rect" href="overriding-exception-reporting.html">Overriding Exception Reporting</a> + <a shape="rect" href="error-page-recipe.html">Error Page Recipe</a> </div> @@ -96,7 +94,7 @@ table.ScrollbarTable td.ScrollbarNextIco <span class="icon icon-page" title="Page">Page:</span> </div> <div class="details"> - <a shape="rect" href="error-page-recipe.html">Error Page Recipe</a> + <a shape="rect" href="specific-errors-faq.html">Specific Errors FAQ</a> </div> @@ -105,22 +103,13 @@ table.ScrollbarTable td.ScrollbarNextIco <span class="icon icon-page" title="Page">Page:</span> </div> <div class="details"> - <a shape="rect" href="specific-errors-faq.html">Specific Errors FAQ</a> + <a shape="rect" href="overriding-exception-reporting.html">Overriding Exception Reporting</a> </div> </li></ul> -</div> - -<h1 id="ErrorPageRecipe-ServingTapestryPagesasServletErrorPages">Serving Tapestry Pages as Servlet Error Pages</h1> - -<p>Do you want to dress up your site and use a snazzy Tapestry page instead of the default 404 error page? Using modern servlet containers, this is a snap!</p> - -<p>Simply upgrade your application web.xml to the 2.4 version, and make a couple of changes:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>web.xml</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ -<?xml version="1.0" encoding="UTF-8"?> +</div><h1 id="ErrorPageRecipe-ServingTapestryPagesasServletErrorPages">Serving Tapestry Pages as Servlet Error Pages</h1><p>Do you want to dress up your site and use a snazzy Tapestry page instead of the default 404 error page? Using modern servlet containers, this is a snap!</p><p>Simply upgrade your application web.xml to the 2.4 version, and make a couple of changes:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>web.xml</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" @@ -150,17 +139,8 @@ table.ScrollbarTable td.ScrollbarNextIco </web-app> ]]></script> -</div></div> - -<p>Tapestry's filter must be marked as a handler for both standard requests and errors. That's accomplished with the <code><dispatcher></code> elements inside the <code><filter-mapping></code> section.</p> - -<p>You must then map error codes to Tapestry URLs. In this case, the 404 error is send to the <code>/error404</code> resource, which is really the "Error404" Tapestry page.</p> - -<p>We'll create a simple Error404 page, one that displays a message and (in development mode) displays the details about the incoming request.</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Error404.tml</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ -<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> +</div></div><p>Tapestry's filter must be marked as a handler for both standard requests and errors. That's accomplished with the <code><dispatcher></code> elements inside the <code><filter-mapping></code> section.</p><p>You must then map error codes to Tapestry URLs. In this case, the 404 error is send to the <code>/error404</code> resource, which is really the "Error404" Tapestry page.</p><p>We'll create a simple Error404 page, one that displays a message and (in development mode) displays the details about the incoming request.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Error404.tml</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"> <head> <title>Resource not found.</title> </head> @@ -175,13 +155,8 @@ table.ScrollbarTable td.ScrollbarNextIco </body> </html> ]]></script> -</div></div> - -<p>The page simply makes the request and productionMode properties available:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Error404.java</b></div><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -package com.example.cookbook.pages; +</div></div><p>The page simply makes the request and productionMode properties available:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Error404.java</b></div><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[package com.example.cookbook.pages; import org.apache.tapestry5.SymbolConstants; import org.apache.tapestry5.annotations.Property; @@ -201,16 +176,10 @@ public class Error404 private boolean productionMode; } ]]></script> -</div></div> - -<p>The end-result, in when <em>not</em> in production mode, looks like this:</p> - -<p><img class="confluence-embedded-image" src="https://cwiki.apache.org/confluence/download/attachments/23336861/Snapz%20Pro%20XScreenSnapz002.png?version=1&modificationDate=1283546257000&api=v2" data-image-src="/confluence/download/attachments/23336861/Snapz%20Pro%20XScreenSnapz002.png?version=1&modificationDate=1283546257000&api=v2"></p> - - <div class="aui-message hint shadowed information-macro"> +</div></div><p>The end-result, in when <em>not</em> in production mode, looks like this:</p><p><img class="confluence-embedded-image" src="https://cwiki.apache.org/confluence/download/attachments/23336861/Snapz%20Pro%20XScreenSnapz002.png?version=1&modificationDate=1283546257000&api=v2" data-image-src="/confluence/download/attachments/23336861/Snapz%20Pro%20XScreenSnapz002.png?version=1&modificationDate=1283546257000&api=v2"></p> <div class="aui-message hint shadowed information-macro"> <span class="aui-icon icon-hint">Icon</span> <div class="message-content"> - <p>An issue with an application that has a root Index page is that any invalid path, which would normally generate a 404 error, is instead routed to the Index page (because the invalid path looks like page's activation context). See <a shape="rect" class="external-link" href="https://issues.apache.org/jira/browse/TAP5-2070">Issue TAP5-2070</a>. </p> + <p>An issue with an application that has a root Index page is that any invalid path, which would normally generate a 404 error, is instead routed to the Index page (because the invalid path looks like page's activation context). See <a shape="rect" class="external-link" href="https://issues.apache.org/jira/browse/TAP5-2070">Issue TAP5-2070</a>.</p> </div> </div></div> </div>