You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by bu...@apache.org on 2015/06/27 23:21:05 UTC

svn commit: r956226 [22/34] - in /websites/production/tapestry/content: ./ 2010/10/11/ 2010/10/31/ 2010/11/18/ 2010/11/19/ 2010/12/16/ 2010/12/17/ 2011/01/10/ 2011/03/29/ 2011/06/13/ 2011/06/24/ 2011/06/29/ 2011/07/29/ 2011/08/16/ 2011/08/27/ 2011/10/3...

Modified: websites/production/tapestry/content/javascript-rewrite-in-54.html
==============================================================================
--- websites/production/tapestry/content/javascript-rewrite-in-54.html (original)
+++ websites/production/tapestry/content/javascript-rewrite-in-54.html Sat Jun 27 21:21:02 2015
@@ -45,7 +45,7 @@
   <input type="submit" value="Search">
 </form>
 
-</div><div class="emblem" style="float:left"><p><a shape="rect" href="index.html"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></a></p></div><div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">JavaScript Rewrite in 5.4</h1></div></div>
+</div><div class="emblem" style="float:left"><p><a shape="rect" href="index.html"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></span></a></p></div><div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">JavaScript Rewrite in 5.4</h1></div></div>
 <div class="clearer"></div>
 </div>
 
@@ -57,18 +57,7 @@
   </div>
 
 <div id="content">
-<div id="ConfluenceContent"><p><style type="text/css">/*<![CDATA[*/
-div.rbtoc1428103168612 {padding: 0px;}
-div.rbtoc1428103168612 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1428103168612 li {margin-left: 0px;padding-left: 0px;}
-
-/*]]>*/</style></p><div class="toc-macro rbtoc1428103168612">
-<ul class="toc-indentation"><li><a shape="rect" href="#JavaScriptRewritein5.4-TapestryandJavaScript">Tapestry and JavaScript</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-TapestryJavaScriptLimitations(through5.3)">Tapestry JavaScript Limitations (through 5.3)</a>
-<ul class="toc-indentation"><li><a shape="rect" href="#JavaScriptRewritein5.4-DependenceonPrototype/Scriptaculous">Dependence on Prototype/Scriptaculous</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-LackofDocumentation">Lack of Documentation</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-LackofModuleStructure">Lack of Module Structure</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-ComplexInitialization">Complex Initialization</a></li></ul>
-</li><li><a shape="rect" href="#JavaScriptRewritein5.4-JavaScriptImprovementsfor5.4">JavaScript Improvements for 5.4</a>
-<ul class="toc-indentation"><li><a shape="rect" href="#JavaScriptRewritein5.4-RequireJS">RequireJS</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-SlowPageLoadandInitialization">Slow Page Load and Initialization</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-MappingModulestoAssets">Mapping Modules to Assets</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-ExtensionstoJavaScriptSupport">Extensions to JavaScriptSupport</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-AvoidingJavaScriptClasses">Avoiding JavaScript Classes</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-ExposeGlobalMessageCatalogtoClient">Expose Global Message Catalog to Client</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-PartialPageUpdateResponse">Partial Page Update Response</a></li></ul>
-</li><li><a shape="rect" href="#JavaScriptRewritein5.4-MaintainingBackwardsCompatibility">Maintaining Backwards Compatibility</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-TwitterBootstrap">Twitter Bootstrap</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-ContentDeliveryNetworkIntegration">Content Delivery Network Integration</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-ExtJSCompatibility">ExtJS Compatibility</a></li><li><a shape="rect" href="#JavaScriptRewritein5.4-MoreThoughts">More Thoughts</a></li></ul>
-</div><h1 id="JavaScriptRewritein5.4-TapestryandJavaScript">Tapestry and JavaScript</h1><p>Tapestry 5 has had a interesting mix of characteristics.</p><p>On the one hand, it has had a large number of features that work, and work well, right out of the box, with no special configuration or setup. This includes client-side validation, dynamic content updates, simple animations, progressive enhancement, and other standard Ajax and DHTML use cases.</p><p>In addition, Tapestry has evolved, from Tapestry 5.0 through 5.3, into a quite capable <em>provisioning</em> framework:</p><ul><li>JavaScript libraries may be combined into <em>stacks</em> that are combined (in production) into a single virtual file</li><li>JavaScript libraries and CSS files may be minified</li><li>Libraries, stacks, and other resources are exposed to the browser with a versioned URL and far-future expires header, to support aggressive client-caching</li><li>Resources, including JavaScript and CSS, can be distributed in
 side JARs (as part of reusable component libraries)</li><li>Compressible resources will be automatically GZip compressed if the client supports it</li></ul><p>However, JavaScript support in Tapestry is still unsatisfactory. Too often, Tapestry falls into an <a shape="rect" class="external-link" href="http://en.wikipedia.org/wiki/Uncanny_valley" >uncanny valley</a> where the framework (server-side and client-side) does so much automatically that it becomes accepted that it does everything ... developers later discover, to their dismay, that the last 10% of custom behavior they desire is very hard to implement, because of all the common problems that plague any complex system: insufficient APIs, unexpected leaky abstractions, or just plain bugs.</p><p>Common examples of the challenges imposed by Tapestry include implementing a Confirm mixin, customizing behavior when a Zone component is dynamically updated, or any number of issues related to Forms, form elements, and Ajax updates.</p>
 <p>This document is a roadmap for how Tapestry 5.4 will revisit the relationship between server-side Java and client-side JavaScript. Ultimately, we hope to convert this relationship from an obstacle to using Tapestry into an essential reason to select Tapestry in the first place.</p><h1 id="JavaScriptRewritein5.4-TapestryJavaScriptLimitations(through5.3)">Tapestry JavaScript Limitations (through 5.3)</h1><h2 id="JavaScriptRewritein5.4-DependenceonPrototype/Scriptaculous">Dependence on Prototype/Scriptaculous</h2><p>Tapestry made an early choice to embrace Prototype and Scriptaculous at a time when this made sense, circa 2006-2007.</p><p>The goal was to have Tapestry provide a client-side API, the <code>Tapestry</code> namespace, that in turn would delegate complex behaviors (including DOM element selection, event management, and XmlHttpRequest processing) to a <em>foundational framework</em>. The goal was to isolate all the direct dependencies on Prototype in such a way that it wou
 ld be possible, in the future, to swap out for a different foundational framework, such as jQuery or ExtJS. Unfortunately, expediency has proven to make this goal even less reachable!</p><h2 id="JavaScriptRewritein5.4-LackofDocumentation">Lack of Documentation</h2><p>There has not, to date, been an adequate documentation of the <code>T5</code> and <code>Tapestry</code> namespaces, beyond the code itself.</p><h2 id="JavaScriptRewritein5.4-LackofModuleStructure">Lack of Module Structure</h2><p>Beyond the basic use of namespaces, Tapestry has not embraced modern JavaScript usage; specifically, it makes limited use of <em>hygenic functions</em> to form modules. Hygenic functions are JavaScript functions that exist as a way to encapsulate private properties and functions. Tapestry 5.3 makes more use of this pattern than previous releases.</p><p>What modularity is present in the JavaScript is organized around the <code>T5.initializers</code> (<code>Tapestry.Initializers</code>) namespace,
  and the mechanics of full-page and partial-page renders (described more fully below).</p><h2 id="JavaScriptRewritein5.4-ComplexInitialization">Complex Initialization</h2><p>Many users are perplexed by how Tapestry performs initialization. In typical web page construction, the developer would create a <code>&lt;script&gt;</code> block at the bottom of the page, and do initializations there. In Tapestry, it can be much more complex:</p><ul><li>A JavaScript library, containing one or more <em>initialization functions</em>, is created</li><li>The initialization functions must be <a shape="rect" class="external-link" href="http://en.wikipedia.org/wiki/Monkey_patching" >monkey patched</a> into the T5.initializers (or older Tapestry.Initializers) namespace.</li><li>The <a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/javascript/JavaScriptSupport.html">JavaScriptSupport</a> environmental must be used to invoke the function
 , by name, passing it a JSONObject to configure itself (the "specification")</li><li>The affected element must have a unique id attribute, used to coordinate the initialization in the client web browser. (Tapestry assists with unique id allocation, but it would be much better if unique ids were not necessary.)</li></ul><p>This often feels like overkill, but it is necessary for a number of desirable characteristics:</p><ul><li>Initialization code occurs in a single Tapestry-generated <code>&lt;script&gt;</code> block at the end of the page (just before the <code>&lt;/body&gt;</code> tag)</li><li>There is limited support for structuring the order of initialization</li><li>The mechanism works transparently in both full-page render requests (traditional) and partial-page render requests (Ajax)</li></ul><p>Despite this, the Tapestry approach can feel very "heavy". In a bespoke page, initialization that may affect many elements of the page often takes the form of a single event handler, a
 ttached to the <code>&lt;body&gt;</code> element, that catches events that bubble up from much lower in the DOM. The single handler function identifies the applicable elements using CSS selectors, including those that are based on HTML5 data- attributes. Additional data- attributes will define additional behavior ... for example, a URL for a triggered request. This is "light" because:</p><ul><li>There's a single event handler function (rather than a unique handler function instance per element)</li><li>The event handler may be anonymous (there's no name, or possibility of collision)</li><li>Elements are identified by DOM structure and CSS rather than their unique id (the element will often not have an id attribute)</li><li>Additional necessary configuration is directly attached to the element, rather than split</li><li>As the page is dynamically updated, there is no extra "bookkeeping" for added or removed elements; new elements inserted into the DOM dynamically are recognized as ea
 sily as those that were present on the initial render</li></ul><p>By contrast, Tapestry is "heavy":</p><ul><li>The initialization function must have a unique name</li><li>The element must have a unique id, to it can be located by the initialization function</li><li>The event handlers are attached directly to the element</li><li>Duplicated elements will have duplicated event handlers</li><li>Additional behavior is specified as a JSON object passed to the initialization function</li><li>Injecting new elements into the DOM requires invoking initialization functions to wire up the necessary event handlers</li><li>In (older versions of) Internet Explorer, removing elements may leave memory leaks as JavaScript objects retain references to DOM objects and vice-versa</li></ul><h1 id="JavaScriptRewritein5.4-JavaScriptImprovementsfor5.4">JavaScript Improvements for 5.4</h1><p>The goals for Tapestry 5.4 are:</p><ul><li>Break the dependency on Prototype and allow Tapestry to be used with any cl
 ient-side "foundation" framework, seamlessly: minimally, this should include jQuery</li><li>Bring Tapestry's JavaScript approach more inline with modern practices (the "light" approach described above)</li><li>Let the JavaScript be modular, and loaded dynamically and asynchonously, only as needed</li><li>Optimize for fast page loads</li><li>Backwards compatibility to the Tapestry 5.3 approach until at least 5.5 or 5.6</li><li>Simplify Tapestry's client-side behavior, but make it easier to hook into, extend, and override</li></ul><h2 id="JavaScriptRewritein5.4-RequireJS">RequireJS</h2><p>Rather than reinvent the wheel, Tapestry should incorporate a proper JavaScript module loader; <a shape="rect" class="external-link" href="http://requirejs.org/" >RequireJS</a> is an excellent candidate, especially considering the new features provided in its 2.0.1 release.</p><p>RequireJS supports the <a shape="rect" class="external-link" href="https://github.com/amdjs/amdjs-api/wiki/AMD" >AMD (Asyn
 chronous Module Format)</a>, with some additional support for the <a shape="rect" class="external-link" href="http://www.commonjs.org/" >CommonJS</a> module format (the format used by Node.js). The latter is simpler, but is designed for a server-side environment; AMD is specifically designed to handle asynchronous loading of JavaScript into a web browser.</p><p>RequireJS is geared towards bespoke applications; for Tapestry it is expected that some of the pathing and other configuration normally done in the client using the RequireJS API will instead by handled more dynamically on the server, using typically Tapestry configuration and extension mechanisms. For example, RequireJS allows mappings of module names to URLs, which is useful when working with multiple third-party JavaScript libraries that may be organized differently form each other. Tapestry can incorporate such logic on the server side instead, making the interface from the browser to the server uniform, even when the det
 ails of where each module is stored is quite variable.</p><h2 id="JavaScriptRewritein5.4-SlowPageLoadandInitialization">Slow Page Load and Initialization</h2><p>Tapestry 5.1 and up has support for dealing with slow page loads (especially, slow loads of extenal JavaScript). This is necessary, because in slow page load situations, the user may submit a form or click a link <em>before</em> page initialization has added an event handler for that submit or click; it was common in those cases for the a traditional request to be sent to the server for a link or form that was expected by the developer to only be accessed via an Ajax request. Without a server-side check (via the <code>Request.isXHR()</code> method), the server-side event handler would return a response that can not be handled in a traditional request, and the user would see the Tapestry exception report page.</p><p>Tapestry 5.3 and earlier would wait for the page loaded event (by observing <a shape="rect" class="external-lin
 k" href="http://api.prototypejs.org/dom/document/observe/" >Prototype's "dom:loaded" event</a>) before executing any JavaScript initialization functions. Likewise, in a partial page render (Ajax) update, it would ensure that all JavaScript libraries had been loaded before executing any initialization functions.</p><p>It is not clear how this same functionality will be supported in Tapestry 5.4 as the asynchronous module loading makes it difficult to know when all modules have been loaded and all initialization functions have been invoked.</p><p>Tapestry 5.4 uses JavaScript to add a "page loading mask", which is removed once all JavaScript has initialized. Using CSS animation tricks, the mask becomes visible after a fraction of a second, and includes a spinning icon. The page loading mask prevents any interaction by the user on the incompletely initialized page.</p><h2 id="JavaScriptRewritein5.4-MappingModulestoAssets">Mapping Modules to Assets</h2><p>Under RequireJS, modules are ide
 ntified by string that represents a kind of virtual path on the server. The path does not start with a scheme, or a slash, or end with a ".js" suffix: in all those cases, RequireJS will load a JavaScript file but not treat it as a dependency.</p><p>On the server side, Tapestry will map the path to a classpath asset.</p><p>There must be provisions for the following options:</p><ul><li>A module may be overridden (for instance, to work around a bug), in which case a specific asset may be used for the module, rather than the default</li><li>A module may need to be converted from one language to another: specifically, a module may be written in CoffeeScript, and need to be compiled down to JavaScript</li><li>A module's content may be aggregated with other related modules (much like a Tapestry 5.3 stack), especially in production. (A request for any module should provide the aggregated set of modules; RequireJS will not need to send additional requests for the other modules.)</li><li>Modu
 le content (aggregated or not) should be minimized</li></ul><p>In addition, it may be reasonable to have Tapestry automatically (or via some configuration) <a shape="rect" class="external-link" href="http://requirejs.org/docs/commonjs.html" >wrap CommonJS modules as AMD modules</a>. (Traditionally, Tapestry has configured this kind of behavior via service contributions, but there is ample evidence that this could be done using external configuration, perhaps using a JSON file in the module package, to control aggregation, wrapping, and other aspects the process. This would be more agile, as it would not require restarts when the configuration changes.)</p><p>Modules will be stored on the classpath, in a <code>modulejs</code> package below each library's root package. Modules within that package are referenced by their name relative to the package. (A rarely used feature of Tapestry is that a component library name may be mapped to multiple packages; resolving a module name may requi
 re a search among the packages. There is the expectation that the developer will ensure that there are no duplications that would lead to ambiguities.)</p><p>Under this system, module <code>core/pubsub</code> would be the file <code>pubsub.js</code> in the package <code>org.apache.tapestry5.corelib.modulejs</code>, since Tapestry's component library 'core' is mapped to package <code>org.apache.tapestry5.corelib</code>.</p><p>Certain key modules, such as <a shape="rect" class="external-link" href="http://documentcloud.github.com/underscore/" >Underscore</a> may be mapped at the root level, as they are used so often.</p><h2 id="JavaScriptRewritein5.4-ExtensionstoJavaScriptSupport">Extensions to JavaScriptSupport</h2><p>A number of new methods will be added to JavaScriptSupport, to support the following behaviors:</p><ul><li>require one or more modules</li><li>require a module (that exports a single function) and invoke the function, passing zero or more values. (Values passed to modul
 e functions may be limited to String and <a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/json/JSONObject.html">JSONObject</a>.)</li><li>require a module and a function name and invoke named function exported by the module, passing zero or more values</li></ul><p>The intent here is to support shifting of client-side behavior from the 5.3 style, an approach that involved monkey-patching functions onto <code>T5.initializers</code>, and move the same logic into modules, preferably with simpler parameters. It is also expected that there will be greater use of <code>data-</code> prefixed HTML5 attributes in place of separate configuration, as outlined above.</p><h2 id="JavaScriptRewritein5.4-AvoidingJavaScriptClasses"><span style="line-height: 1.5;">Avoiding JavaScript Classes</span></h2><p>Much of the logic for important operations, such as client-side validation (and input field decoration), are based on the use of client-side 
 <a shape="rect" class="external-link" href="http://api.prototypejs.org/language/Class/" >JavaScript classes</a>. This has been somewhat valuable in terms of making the behavior controllable via monkey patching. On the other hand, it cam be clumsy to accomplish in practice, as the desired behavior is only described in terms of the implementation.</p><p>In addition, these JavaScript class instances are yet more memory for the browser to manage.</p><p>By using a fine-grained set of PubSub messages, the logic usually bundled into a single JavaScript class can be assembled (and, in theory, replaced) more easily. In addition, Tapestry can do less. For instance, rather than monkey-patching the <code>Tapestry.ZoneManager</code> class to enable new behavior when a Zone element is updated, relying on a PubSub message to learn when the Zone was updated, and perform the desired updates or animations there.</p><h2 id="JavaScriptRewritein5.4-ExposeGlobalMessageCatalogtoClient">Expose Global Messa
 ge Catalog to Client</h2><p>Tapestry currently maintains two global message catalogs; a global server-side catalog (usually named <code>WEB-INF/app.properties) and a client-side catalog. (app.properties provides application-specific messages, and overrides of other messages provided by Tapestry and other third-party libraries. The global message catalog is actually a composite of all of these sources.) </code>The client-side catalog is smaller, more limited, and less extensible.</p><p>Allowing the client application to have full access to the entire message catalog would make maintaining the catalog simpler, and make it easier to keep client-side and server-side messages consistent.</p><p>For security purposes, it should be possible to exclude some keys from the message catalog exposed to the client. In addition, keys whose values include <code>String.format()</code> productions (for example, <code>%s</code>) should be excluded, as those productions are meaningless in the client.</p
 ><h2 id="JavaScriptRewritein5.4-PartialPageUpdateResponse">Partial Page Update Response</h2><p>A key part of Tapestry's dynamic behavior has been the partial page update; a specific JSON reply to Ajax requests (usually initiated via a Zone component).</p><p>The format and behavior of the response has evolved from release to release.</p><p>When an Ajax request is processed by the server, the response should handle any of a number of outcomes:</p><ul><li>Redirect the entire page to a new URL (on the server, or elsewhere)</li><li>A server-side error to be presented to the user. (This was greatly enhanced in 5.3 to present the full exception report in a pop-up iframe.)</li><li>Update the content of an implicit (originating) element; typically the element for the Zone that triggered the request</li><li>Update the content of any number of other elements (identified by their client-side id)</li><li>Inject new JavaScript libraries into the page</li><li>Inject new CSS links into the page</li
 ><li>Peform initializations (using <code>T5.initializers</code>) ... but only after all content updates have occurred</li></ul><p>The injected JavaScript libraries and CSS links will often duplicate libraries and CSS links already present on the page; when the page is partially rendered, the server has no way to know what full or partial page renders have already occurred. (It might be possible for the request to include a list of what's already loaded in the browser, so that the server can filter what it sends back; however, given factors such as content compression and typical upload vs. download bandwidth, it is almost certainly more effective for the browser to send too much, and let the client filter out duplicates.)</p><p>Tapestry 5.3 first loads any additional JavaScript (usually by adding new <code>&lt;script&gt;</code> tags to the page). Once JavaScript libraries and CSS links have been added, and JavaScript libraries have been loaded, the DOM is updated with the new conten
 t. Lastly, any initializations are processed.</p><p>For Tapestry 5.4, a number of changes are planned:</p><ul><li>Tapestry 5.3 style initializations will be a specific application of 5.4 style module requirement and invocation</li><li><a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/javascript/InitializationPriority.html#IMMEDIATE">IMMEDIATE</a> may occur before DOM changes</li><li>Module requirement/invocation will occur in <a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/javascript/InitializationPriority.html">initialization priority order</a>; for any single priority, initialization will occur in render order. (Technically, in the order of invocations on JavaScriptSupport.)</li><li>The response will be embeddable inside other JSONObject responses.</li></ul><p>To expand on the last note first; the keys that define imported JavaScript and CSS, modu
 le requirement and invocation, and content update will not be top-level keys of the JSONObject response: they will be buried inside a <code>tapestry</code> top-level key. An available function will be provided that takes an arbitrary JSONObject, extracts the <code>tapestry</code> key and handles it, then invokes a provided callback before the module requirement and invocation step. The intent is for requests that perform purely data oriented operations, the server-side can not only provide a response, but can <em>piggy back</em> client-side updates in the response.</p><h1 id="JavaScriptRewritein5.4-MaintainingBackwardsCompatibility">Maintaining Backwards Compatibility</h1><p>Backwards compatibility is the greatest challenge here; ideally, applications (and third party libraries) that were written for Tapestry 5.3 will continue to operate unchanged in Tapestry 5.4.</p><p>At the same time, much of what Tapestry 5.3 does on the client and server should be deprecated (and hopefully, sim
 plified).</p><p>Compatibility mode will be initially enabled, via a <a shape="rect" href="symbols.html">symbol</a> value.</p><p>In compatibility mode, additional client-side JavaScript will be loaded to provide the same <code>T5</code> and <code>Tapestry</code> namespaces available in Tapestry 5.3.</p><p>The implementations of these namespaces will be reconstructed in terms of the new module system. The loading of the compatibility layer will occur during full page render.</p><h1 id="JavaScriptRewritein5.4-TwitterBootstrap">Twitter Bootstrap</h1><p>In Tapestry 5.3 and earlier, Tapestry automatically includes a default CSS link on all pages. This CSS file acts as a partial CSS reset (normalizing the look of the application across common browsers), and provides a large number of CSS rules that many Tapestry components expect to be present. The CSS rules are all given a "t-" (for Tapestry) prefix.</p><p>For Tapestry 5.4, this default CSS link will be changed to be the default <a shape=
 "rect" class="external-link" href="http://twitter.github.com/bootstrap/" >Twitter Bootstrap</a>. This will not only refresh the Tapestry look and feel, but will provide a better structure for customizing the application's look and feel.</p><p>As with today, it will be possible to override the location of this CSS file (for example, to use a newer version of Bootstrap than is packaged in the application, or an application-specific customized version).</p><p>This will entail some changes to some components, to make use of reasonable or equivalent Bootstrap CSS classes, rather than the Tapestry 5.3 classes.</p><p>Twitter Bootstrap also includes a number of jQuery-based plugins; these will be exposed in the module system.</p><h1 id="JavaScriptRewritein5.4-ContentDeliveryNetworkIntegration">Content Delivery Network Integration</h1><p>Tapestry 5.3 has limited ability to integrate into a <a shape="rect" class="external-link" href="http://en.wikipedia.org/wiki/Content_delivery_network" >con
 tent delivery network</a>; it can dynamically rewrite URLs for assets (including JavaScript libraries, CSS files, image files, etc.). However, it assumes that the CDN can "pull" the content, as needed, from the live site.</p><p>A desirable feature would be request URL that would produce a JSON-formatted report of all assets that should be mirrored by the CDN: this would include all files that might be exposed to the browser, including virtual assets (such as JavaScript stacks, aggregated modules, and so forth). This could be leveraged by a tool that would use this information to extract the assets from the live application and exported to the CDN.</p><p>Determining what assets are available is somewhat problematic as Tapestry mixes server-side only resources (.class files, .tml files, etc.) freely with assets that might be exposed to the browser. (This should never have been the case, but that's hindsight.) Some of those server-side resource may expose details, such as other server 
 hosts and potentially user names and passwords, that should never be exposed to the client.</p><p>In addition, a "walk" of the classpath to locate potential exportable assets can be quite expensive (though not considerably more so than what Tapestry already does at startup to identify page and component classes).</p><h1 id="JavaScriptRewritein5.4-ExtJSCompatibility">ExtJS Compatibility</h1><p>To be determined. ExtJS inlcudes it own system for dynamically loading ExtJS modules, as well as expressing dependencies between them. Its capabilities overlap what RequireJS offers. It would be nice if, in an ExtJS application, the ExtJS loader could be used instead of RequireJS, or at least, ensure that they do not interfere with each other.</p><h1 id="JavaScriptRewritein5.4-MoreThoughts">More Thoughts</h1><p>This is a big undertaking; this document is not a contract, and is certainly not complete, but is only starting point for discussions about what will be forthcoming in Tapestry 5.4.</p><
 /div>
+<div id="ConfluenceContent"><div class="toc-macro client-side-toc-macro" data-headerelements="H1,H2,H3,H4,H5,H6,H7"></div><h1 id="JavaScriptRewritein5.4-TapestryandJavaScript">Tapestry and JavaScript</h1><p>Tapestry 5 has had a interesting mix of characteristics.</p><p>On the one hand, it has had a large number of features that work, and work well, right out of the box, with no special configuration or setup. This includes client-side validation, dynamic content updates, simple animations, progressive enhancement, and other standard Ajax and DHTML use cases.</p><p>In addition, Tapestry has evolved, from Tapestry 5.0 through 5.3, into a quite capable <em>provisioning</em> framework:</p><ul><li>JavaScript libraries may be combined into <em>stacks</em> that are combined (in production) into a single virtual file</li><li>JavaScript libraries and CSS files may be minified</li><li>Libraries, stacks, and other resources are exposed to the browser with a versioned URL and far-future expires
  header, to support aggressive client-caching</li><li>Resources, including JavaScript and CSS, can be distributed inside JARs (as part of reusable component libraries)</li><li>Compressible resources will be automatically GZip compressed if the client supports it</li></ul><p>However, JavaScript support in Tapestry is still unsatisfactory. Too often, Tapestry falls into an <a shape="rect" class="external-link" href="http://en.wikipedia.org/wiki/Uncanny_valley" >uncanny valley</a> where the framework (server-side and client-side) does so much automatically that it becomes accepted that it does everything ... developers later discover, to their dismay, that the last 10% of custom behavior they desire is very hard to implement, because of all the common problems that plague any complex system: insufficient APIs, unexpected leaky abstractions, or just plain bugs.</p><p>Common examples of the challenges imposed by Tapestry include implementing a Confirm mixin, customizing behavior when a Z
 one component is dynamically updated, or any number of issues related to Forms, form elements, and Ajax updates.</p><p>This document is a roadmap for how Tapestry 5.4 will revisit the relationship between server-side Java and client-side JavaScript. Ultimately, we hope to convert this relationship from an obstacle to using Tapestry into an essential reason to select Tapestry in the first place.</p><h1 id="JavaScriptRewritein5.4-TapestryJavaScriptLimitations(through5.3)">Tapestry JavaScript Limitations (through 5.3)</h1><h2 id="JavaScriptRewritein5.4-DependenceonPrototype/Scriptaculous">Dependence on Prototype/Scriptaculous</h2><p>Tapestry made an early choice to embrace Prototype and Scriptaculous at a time when this made sense, circa 2006-2007.</p><p>The goal was to have Tapestry provide a client-side API, the <code>Tapestry</code> namespace, that in turn would delegate complex behaviors (including DOM element selection, event management, and XmlHttpRequest processing) to a <em>fou
 ndational framework</em>. The goal was to isolate all the direct dependencies on Prototype in such a way that it would be possible, in the future, to swap out for a different foundational framework, such as jQuery or ExtJS. Unfortunately, expediency has proven to make this goal even less reachable!</p><h2 id="JavaScriptRewritein5.4-LackofDocumentation">Lack of Documentation</h2><p>There has not, to date, been an adequate documentation of the <code>T5</code> and <code>Tapestry</code> namespaces, beyond the code itself.</p><h2 id="JavaScriptRewritein5.4-LackofModuleStructure">Lack of Module Structure</h2><p>Beyond the basic use of namespaces, Tapestry has not embraced modern JavaScript usage; specifically, it makes limited use of <em>hygenic functions</em> to form modules. Hygenic functions are JavaScript functions that exist as a way to encapsulate private properties and functions. Tapestry 5.3 makes more use of this pattern than previous releases.</p><p>What modularity is present in
  the JavaScript is organized around the <code>T5.initializers</code> (<code>Tapestry.Initializers</code>) namespace, and the mechanics of full-page and partial-page renders (described more fully below).</p><h2 id="JavaScriptRewritein5.4-ComplexInitialization">Complex Initialization</h2><p>Many users are perplexed by how Tapestry performs initialization. In typical web page construction, the developer would create a <code>&lt;script&gt;</code> block at the bottom of the page, and do initializations there. In Tapestry, it can be much more complex:</p><ul><li>A JavaScript library, containing one or more <em>initialization functions</em>, is created</li><li>The initialization functions must be <a shape="rect" class="external-link" href="http://en.wikipedia.org/wiki/Monkey_patching" >monkey patched</a> into the T5.initializers (or older Tapestry.Initializers) namespace.</li><li>The <a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5
 /services/javascript/JavaScriptSupport.html">JavaScriptSupport</a> environmental must be used to invoke the function, by name, passing it a JSONObject to configure itself (the "specification")</li><li>The affected element must have a unique id attribute, used to coordinate the initialization in the client web browser. (Tapestry assists with unique id allocation, but it would be much better if unique ids were not necessary.)</li></ul><p>This often feels like overkill, but it is necessary for a number of desirable characteristics:</p><ul><li>Initialization code occurs in a single Tapestry-generated <code>&lt;script&gt;</code> block at the end of the page (just before the <code>&lt;/body&gt;</code> tag)</li><li>There is limited support for structuring the order of initialization</li><li>The mechanism works transparently in both full-page render requests (traditional) and partial-page render requests (Ajax)</li></ul><p>Despite this, the Tapestry approach can feel very "heavy". In a besp
 oke page, initialization that may affect many elements of the page often takes the form of a single event handler, attached to the <code>&lt;body&gt;</code> element, that catches events that bubble up from much lower in the DOM. The single handler function identifies the applicable elements using CSS selectors, including those that are based on HTML5 data- attributes. Additional data- attributes will define additional behavior ... for example, a URL for a triggered request. This is "light" because:</p><ul><li>There's a single event handler function (rather than a unique handler function instance per element)</li><li>The event handler may be anonymous (there's no name, or possibility of collision)</li><li>Elements are identified by DOM structure and CSS rather than their unique id (the element will often not have an id attribute)</li><li>Additional necessary configuration is directly attached to the element, rather than split</li><li>As the page is dynamically updated, there is no ex
 tra "bookkeeping" for added or removed elements; new elements inserted into the DOM dynamically are recognized as easily as those that were present on the initial render</li></ul><p>By contrast, Tapestry is "heavy":</p><ul><li>The initialization function must have a unique name</li><li>The element must have a unique id, to it can be located by the initialization function</li><li>The event handlers are attached directly to the element</li><li>Duplicated elements will have duplicated event handlers</li><li>Additional behavior is specified as a JSON object passed to the initialization function</li><li>Injecting new elements into the DOM requires invoking initialization functions to wire up the necessary event handlers</li><li>In (older versions of) Internet Explorer, removing elements may leave memory leaks as JavaScript objects retain references to DOM objects and vice-versa</li></ul><h1 id="JavaScriptRewritein5.4-JavaScriptImprovementsfor5.4">JavaScript Improvements for 5.4</h1><p>Th
 e goals for Tapestry 5.4 are:</p><ul><li>Break the dependency on Prototype and allow Tapestry to be used with any client-side "foundation" framework, seamlessly: minimally, this should include jQuery</li><li>Bring Tapestry's JavaScript approach more inline with modern practices (the "light" approach described above)</li><li>Let the JavaScript be modular, and loaded dynamically and asynchonously, only as needed</li><li>Optimize for fast page loads</li><li>Backwards compatibility to the Tapestry 5.3 approach until at least 5.5 or 5.6</li><li>Simplify Tapestry's client-side behavior, but make it easier to hook into, extend, and override</li></ul><h2 id="JavaScriptRewritein5.4-RequireJS">RequireJS</h2><p>Rather than reinvent the wheel, Tapestry should incorporate a proper JavaScript module loader; <a shape="rect" class="external-link" href="http://requirejs.org/" >RequireJS</a> is an excellent candidate, especially considering the new features provided in its 2.0.1 release.</p><p>Requir
 eJS supports the <a shape="rect" class="external-link" href="https://github.com/amdjs/amdjs-api/wiki/AMD" >AMD (Asynchronous Module Format)</a>, with some additional support for the <a shape="rect" class="external-link" href="http://www.commonjs.org/" >CommonJS</a> module format (the format used by Node.js). The latter is simpler, but is designed for a server-side environment; AMD is specifically designed to handle asynchronous loading of JavaScript into a web browser.</p><p>RequireJS is geared towards bespoke applications; for Tapestry it is expected that some of the pathing and other configuration normally done in the client using the RequireJS API will instead by handled more dynamically on the server, using typically Tapestry configuration and extension mechanisms. For example, RequireJS allows mappings of module names to URLs, which is useful when working with multiple third-party JavaScript libraries that may be organized differently form each other. Tapestry can incorporate s
 uch logic on the server side instead, making the interface from the browser to the server uniform, even when the details of where each module is stored is quite variable.</p><h2 id="JavaScriptRewritein5.4-SlowPageLoadandInitialization">Slow Page Load and Initialization</h2><p>Tapestry 5.1 and up has support for dealing with slow page loads (especially, slow loads of extenal JavaScript). This is necessary, because in slow page load situations, the user may submit a form or click a link <em>before</em> page initialization has added an event handler for that submit or click; it was common in those cases for the a traditional request to be sent to the server for a link or form that was expected by the developer to only be accessed via an Ajax request. Without a server-side check (via the <code>Request.isXHR()</code> method), the server-side event handler would return a response that can not be handled in a traditional request, and the user would see the Tapestry exception report page.</
 p><p>Tapestry 5.3 and earlier would wait for the page loaded event (by observing <a shape="rect" class="external-link" href="http://api.prototypejs.org/dom/document/observe/" >Prototype's "dom:loaded" event</a>) before executing any JavaScript initialization functions. Likewise, in a partial page render (Ajax) update, it would ensure that all JavaScript libraries had been loaded before executing any initialization functions.</p><p>It is not clear how this same functionality will be supported in Tapestry 5.4 as the asynchronous module loading makes it difficult to know when all modules have been loaded and all initialization functions have been invoked.</p><p>Tapestry 5.4 uses JavaScript to add a "page loading mask", which is removed once all JavaScript has initialized. Using CSS animation tricks, the mask becomes visible after a fraction of a second, and includes a spinning icon. The page loading mask prevents any interaction by the user on the incompletely initialized page.</p><h2 
 id="JavaScriptRewritein5.4-MappingModulestoAssets">Mapping Modules to Assets</h2><p>Under RequireJS, modules are identified by string that represents a kind of virtual path on the server. The path does not start with a scheme, or a slash, or end with a ".js" suffix: in all those cases, RequireJS will load a JavaScript file but not treat it as a dependency.</p><p>On the server side, Tapestry will map the path to a classpath asset.</p><p>There must be provisions for the following options:</p><ul><li>A module may be overridden (for instance, to work around a bug), in which case a specific asset may be used for the module, rather than the default</li><li>A module may need to be converted from one language to another: specifically, a module may be written in CoffeeScript, and need to be compiled down to JavaScript</li><li>A module's content may be aggregated with other related modules (much like a Tapestry 5.3 stack), especially in production. (A request for any module should provide the
  aggregated set of modules; RequireJS will not need to send additional requests for the other modules.)</li><li>Module content (aggregated or not) should be minimized</li></ul><p>In addition, it may be reasonable to have Tapestry automatically (or via some configuration) <a shape="rect" class="external-link" href="http://requirejs.org/docs/commonjs.html" >wrap CommonJS modules as AMD modules</a>. (Traditionally, Tapestry has configured this kind of behavior via service contributions, but there is ample evidence that this could be done using external configuration, perhaps using a JSON file in the module package, to control aggregation, wrapping, and other aspects the process. This would be more agile, as it would not require restarts when the configuration changes.)</p><p>Modules will be stored on the classpath, in a <code>modulejs</code> package below each library's root package. Modules within that package are referenced by their name relative to the package. (A rarely used featur
 e of Tapestry is that a component library name may be mapped to multiple packages; resolving a module name may require a search among the packages. There is the expectation that the developer will ensure that there are no duplications that would lead to ambiguities.)</p><p>Under this system, module <code>core/pubsub</code> would be the file <code>pubsub.js</code> in the package <code>org.apache.tapestry5.corelib.modulejs</code>, since Tapestry's component library 'core' is mapped to package <code>org.apache.tapestry5.corelib</code>.</p><p>Certain key modules, such as <a shape="rect" class="external-link" href="http://documentcloud.github.com/underscore/" >Underscore</a> may be mapped at the root level, as they are used so often.</p><h2 id="JavaScriptRewritein5.4-ExtensionstoJavaScriptSupport">Extensions to JavaScriptSupport</h2><p>A number of new methods will be added to JavaScriptSupport, to support the following behaviors:</p><ul><li>require one or more modules</li><li>require a m
 odule (that exports a single function) and invoke the function, passing zero or more values. (Values passed to module functions may be limited to String and <a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/json/JSONObject.html">JSONObject</a>.)</li><li>require a module and a function name and invoke named function exported by the module, passing zero or more values</li></ul><p>The intent here is to support shifting of client-side behavior from the 5.3 style, an approach that involved monkey-patching functions onto <code>T5.initializers</code>, and move the same logic into modules, preferably with simpler parameters. It is also expected that there will be greater use of <code>data-</code> prefixed HTML5 attributes in place of separate configuration, as outlined above.</p><h2 id="JavaScriptRewritein5.4-AvoidingJavaScriptClasses"><span style="line-height: 1.5;">Avoiding JavaScript Classes</span></h2><p>Much of the logic for imp
 ortant operations, such as client-side validation (and input field decoration), are based on the use of client-side <a shape="rect" class="external-link" href="http://api.prototypejs.org/language/Class/" >JavaScript classes</a>. This has been somewhat valuable in terms of making the behavior controllable via monkey patching. On the other hand, it cam be clumsy to accomplish in practice, as the desired behavior is only described in terms of the implementation.</p><p>In addition, these JavaScript class instances are yet more memory for the browser to manage.</p><p>By using a fine-grained set of PubSub messages, the logic usually bundled into a single JavaScript class can be assembled (and, in theory, replaced) more easily. In addition, Tapestry can do less. For instance, rather than monkey-patching the <code>Tapestry.ZoneManager</code> class to enable new behavior when a Zone element is updated, relying on a PubSub message to learn when the Zone was updated, and perform the desired up
 dates or animations there.</p><h2 id="JavaScriptRewritein5.4-ExposeGlobalMessageCatalogtoClient">Expose Global Message Catalog to Client</h2><p>Tapestry currently maintains two global message catalogs; a global server-side catalog (usually named <code>WEB-INF/app.properties) and a client-side catalog. (app.properties provides application-specific messages, and overrides of other messages provided by Tapestry and other third-party libraries. The global message catalog is actually a composite of all of these sources.) </code>The client-side catalog is smaller, more limited, and less extensible.</p><p>Allowing the client application to have full access to the entire message catalog would make maintaining the catalog simpler, and make it easier to keep client-side and server-side messages consistent.</p><p>For security purposes, it should be possible to exclude some keys from the message catalog exposed to the client. In addition, keys whose values include <code>String.format()</code> p
 roductions (for example, <code>%s</code>) should be excluded, as those productions are meaningless in the client.</p><h2 id="JavaScriptRewritein5.4-PartialPageUpdateResponse">Partial Page Update Response</h2><p>A key part of Tapestry's dynamic behavior has been the partial page update; a specific JSON reply to Ajax requests (usually initiated via a Zone component).</p><p>The format and behavior of the response has evolved from release to release.</p><p>When an Ajax request is processed by the server, the response should handle any of a number of outcomes:</p><ul><li>Redirect the entire page to a new URL (on the server, or elsewhere)</li><li>A server-side error to be presented to the user. (This was greatly enhanced in 5.3 to present the full exception report in a pop-up iframe.)</li><li>Update the content of an implicit (originating) element; typically the element for the Zone that triggered the request</li><li>Update the content of any number of other elements (identified by their 
 client-side id)</li><li>Inject new JavaScript libraries into the page</li><li>Inject new CSS links into the page</li><li>Peform initializations (using <code>T5.initializers</code>) ... but only after all content updates have occurred</li></ul><p>The injected JavaScript libraries and CSS links will often duplicate libraries and CSS links already present on the page; when the page is partially rendered, the server has no way to know what full or partial page renders have already occurred. (It might be possible for the request to include a list of what's already loaded in the browser, so that the server can filter what it sends back; however, given factors such as content compression and typical upload vs. download bandwidth, it is almost certainly more effective for the browser to send too much, and let the client filter out duplicates.)</p><p>Tapestry 5.3 first loads any additional JavaScript (usually by adding new <code>&lt;script&gt;</code> tags to the page). Once JavaScript librar
 ies and CSS links have been added, and JavaScript libraries have been loaded, the DOM is updated with the new content. Lastly, any initializations are processed.</p><p>For Tapestry 5.4, a number of changes are planned:</p><ul><li>Tapestry 5.3 style initializations will be a specific application of 5.4 style module requirement and invocation</li><li><a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/javascript/InitializationPriority.html#IMMEDIATE">IMMEDIATE</a> may occur before DOM changes</li><li>Module requirement/invocation will occur in <a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/javascript/InitializationPriority.html">initialization priority order</a>; for any single priority, initialization will occur in render order. (Technically, in the order of invocations on JavaScriptSupport.)</li><li>The response will be embeddable inside other JSONOb
 ject responses.</li></ul><p>To expand on the last note first; the keys that define imported JavaScript and CSS, module requirement and invocation, and content update will not be top-level keys of the JSONObject response: they will be buried inside a <code>tapestry</code> top-level key. An available function will be provided that takes an arbitrary JSONObject, extracts the <code>tapestry</code> key and handles it, then invokes a provided callback before the module requirement and invocation step. The intent is for requests that perform purely data oriented operations, the server-side can not only provide a response, but can <em>piggy back</em> client-side updates in the response.</p><h1 id="JavaScriptRewritein5.4-MaintainingBackwardsCompatibility">Maintaining Backwards Compatibility</h1><p>Backwards compatibility is the greatest challenge here; ideally, applications (and third party libraries) that were written for Tapestry 5.3 will continue to operate unchanged in Tapestry 5.4.</p><
 p>At the same time, much of what Tapestry 5.3 does on the client and server should be deprecated (and hopefully, simplified).</p><p>Compatibility mode will be initially enabled, via a <a shape="rect" href="symbols.html">symbol</a> value.</p><p>In compatibility mode, additional client-side JavaScript will be loaded to provide the same <code>T5</code> and <code>Tapestry</code> namespaces available in Tapestry 5.3.</p><p>The implementations of these namespaces will be reconstructed in terms of the new module system. The loading of the compatibility layer will occur during full page render.</p><h1 id="JavaScriptRewritein5.4-TwitterBootstrap">Twitter Bootstrap</h1><p>In Tapestry 5.3 and earlier, Tapestry automatically includes a default CSS link on all pages. This CSS file acts as a partial CSS reset (normalizing the look of the application across common browsers), and provides a large number of CSS rules that many Tapestry components expect to be present. The CSS rules are all given a "
 t-" (for Tapestry) prefix.</p><p>For Tapestry 5.4, this default CSS link will be changed to be the default <a shape="rect" class="external-link" href="http://twitter.github.com/bootstrap/" >Twitter Bootstrap</a>. This will not only refresh the Tapestry look and feel, but will provide a better structure for customizing the application's look and feel.</p><p>As with today, it will be possible to override the location of this CSS file (for example, to use a newer version of Bootstrap than is packaged in the application, or an application-specific customized version).</p><p>This will entail some changes to some components, to make use of reasonable or equivalent Bootstrap CSS classes, rather than the Tapestry 5.3 classes.</p><p>Twitter Bootstrap also includes a number of jQuery-based plugins; these will be exposed in the module system.</p><h1 id="JavaScriptRewritein5.4-ContentDeliveryNetworkIntegration">Content Delivery Network Integration</h1><p>Tapestry 5.3 has limited ability to inte
 grate into a <a shape="rect" class="external-link" href="http://en.wikipedia.org/wiki/Content_delivery_network" >content delivery network</a>; it can dynamically rewrite URLs for assets (including JavaScript libraries, CSS files, image files, etc.). However, it assumes that the CDN can "pull" the content, as needed, from the live site.</p><p>A desirable feature would be request URL that would produce a JSON-formatted report of all assets that should be mirrored by the CDN: this would include all files that might be exposed to the browser, including virtual assets (such as JavaScript stacks, aggregated modules, and so forth). This could be leveraged by a tool that would use this information to extract the assets from the live application and exported to the CDN.</p><p>Determining what assets are available is somewhat problematic as Tapestry mixes server-side only resources (.class files, .tml files, etc.) freely with assets that might be exposed to the browser. (This should never hav
 e been the case, but that's hindsight.) Some of those server-side resource may expose details, such as other server hosts and potentially user names and passwords, that should never be exposed to the client.</p><p>In addition, a "walk" of the classpath to locate potential exportable assets can be quite expensive (though not considerably more so than what Tapestry already does at startup to identify page and component classes).</p><h1 id="JavaScriptRewritein5.4-ExtJSCompatibility">ExtJS Compatibility</h1><p>To be determined. ExtJS inlcudes it own system for dynamically loading ExtJS modules, as well as expressing dependencies between them. Its capabilities overlap what RequireJS offers. It would be nice if, in an ExtJS application, the ExtJS loader could be used instead of RequireJS, or at least, ensure that they do not interfere with each other.</p><h1 id="JavaScriptRewritein5.4-MoreThoughts">More Thoughts</h1><p>This is a big undertaking; this document is not a contract, and is cer
 tainly not complete, but is only starting point for discussions about what will be forthcoming in Tapestry 5.4.</p></div>
 </div>
 
 <div class="clearer"></div>

Modified: websites/production/tapestry/content/javascript.html
==============================================================================
--- websites/production/tapestry/content/javascript.html (original)
+++ websites/production/tapestry/content/javascript.html Sat Jun 27 21:21:02 2015
@@ -45,7 +45,7 @@
   <input type="submit" value="Search">
 </form>
 
-</div><div class="emblem" style="float:left"><p><a shape="rect" href="index.html"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></a></p></div><div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">JavaScript</h1></div></div>
+</div><div class="emblem" style="float:left"><p><a shape="rect" href="index.html"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></span></a></p></div><div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">JavaScript</h1></div></div>
 <div class="clearer"></div>
 </div>
 

Modified: websites/production/tapestry/content/jmx-module.html
==============================================================================
--- websites/production/tapestry/content/jmx-module.html (original)
+++ websites/production/tapestry/content/jmx-module.html Sat Jun 27 21:21:02 2015
@@ -45,7 +45,7 @@
   <input type="submit" value="Search">
 </form>
 
-</div><div class="emblem" style="float:left"><p><a shape="rect" href="index.html"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></a></p></div><div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">JMX Module</h1></div></div>
+</div><div class="emblem" style="float:left"><p><a shape="rect" href="index.html"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></span></a></p></div><div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">JMX Module</h1></div></div>
 <div class="clearer"></div>
 </div>
 

Modified: websites/production/tapestry/content/json.html
==============================================================================
--- websites/production/tapestry/content/json.html (original)
+++ websites/production/tapestry/content/json.html Sat Jun 27 21:21:02 2015
@@ -45,7 +45,7 @@
   <input type="submit" value="Search">
 </form>
 
-</div><div class="emblem" style="float:left"><p><a shape="rect" href="index.html"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></a></p></div><div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">JSON</h1></div></div>
+</div><div class="emblem" style="float:left"><p><a shape="rect" href="index.html"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></span></a></p></div><div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">JSON</h1></div></div>
 <div class="clearer"></div>
 </div>
 

Modified: websites/production/tapestry/content/key-features.html
==============================================================================
--- websites/production/tapestry/content/key-features.html (original)
+++ websites/production/tapestry/content/key-features.html Sat Jun 27 21:21:02 2015
@@ -45,7 +45,7 @@
   <input type="submit" value="Search">
 </form>
 
-</div><div class="emblem" style="float:left"><p><a shape="rect" href="index.html"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></a></p></div><div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">Key Features</h1></div></div>
+</div><div class="emblem" style="float:left"><p><a shape="rect" href="index.html"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></span></a></p></div><div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">Key Features</h1></div></div>
 <div class="clearer"></div>
 </div>
 

Modified: websites/production/tapestry/content/layout-component.html
==============================================================================
--- websites/production/tapestry/content/layout-component.html (original)
+++ websites/production/tapestry/content/layout-component.html Sat Jun 27 21:21:02 2015
@@ -27,16 +27,6 @@
   </title>
   <link type="text/css" rel="stylesheet" href="/resources/space.css">
 
-    <link href='/resources/highlighter/styles/shCoreCXF.css' rel='stylesheet' type='text/css' />
-  <link href='/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet' type='text/css' />
-  <script src='/resources/highlighter/scripts/shCore.js' type='text/javascript'></script>
-  <script src='/resources/highlighter/scripts/shBrushJava.js' type='text/javascript'></script>
-  <script src='/resources/highlighter/scripts/shBrushXml.js' type='text/javascript'></script>
-  <script src='/resources/highlighter/scripts/shBrushPlain.js' type='text/javascript'></script>
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
   <link href="/styles/style.css" rel="stylesheet" type="text/css"/>
 
@@ -55,7 +45,7 @@
   <input type="submit" value="Search">
 </form>
 
-</div><div class="emblem" style="float:left"><p><a shape="rect" href="index.html"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></a></p></div><div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">Layout Component</h1></div></div>
+</div><div class="emblem" style="float:left"><p><a shape="rect" href="index.html"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></span></a></p></div><div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">Layout Component</h1></div></div>
 <div class="clearer"></div>
 </div>
 
@@ -68,64 +58,8 @@
 
 <div id="content">
 <div id="ConfluenceContent"><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="component-parameters.html">Component Parameters</a>
-                    
-                
-                            </div>
-        </li><li>
-            <div>
-                    <span class="icon icon-page" title="Page">Page:</span>            </div>
-
-            <div class="details">
-                            <a shape="rect" href="component-cheat-sheet.html">Component Cheat Sheet</a>
-                    
-                
-                            </div>
-        </li><li>
-            <div>
-                    <span class="icon icon-page" title="Page">Page:</span>            </div>
-
-            <div class="details">
-                            <a shape="rect" href="page-and-component-classes-faq.html">Page And Component Classes FAQ</a>
-                    
-                
-                            </div>
-        </li><li>
-            <div>
-                    <span class="icon icon-page" title="Page">Page:</span>            </div>
-
-            <div class="details">
-                            <a shape="rect" href="component-classes.html">Component Classes</a>
-                    
-                
-                            </div>
-        </li><li>
-            <div>
-                    <span class="icon icon-page" title="Page">Page:</span>            </div>
-
-            <div class="details">
-                            <a shape="rect" href="component-templates.html">Component Templates</a>
-                    
-                
-                            </div>
-        </li><li>
-            <div>
-                    <span class="icon icon-page" title="Page">Page:</span>            </div>
-
-            <div class="details">
-                            <a shape="rect" href="templating-and-markup-faq.html">Templating and Markup FAQ</a>
-                    
-                
-                            </div>
-        </li></ul>
-</div><p>You'll see frequent reference to a <strong>Layout Component</strong> in Tapestry documentation, but you won't find such a component in the <a shape="rect" href="component-reference.html">component reference</a>. The Layout component is a component <em>that you create</em> to provide common elements across all of your pages.</p><p>In traditional servlet development, you may be familiar with the use of a JSP include to include a banner across the top of your page and a copyright message across the bottom. In Tapestry, you <em>could</em> implement those recurring page elements as components (a banner component, a copyright component, etc.) and then add those components to every page.</p><p>But there's an even better way. Just create a layout component that provides the overall structure and recurring content for your pages:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Layout.tml (a templa
 te for a Layout component)</b></div><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;html xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_4.xsd&quot;&gt;
+<div class="error"><span class="error">Error formatting macro: contentbylabel: com.atlassian.confluence.api.service.exceptions.BadRequestException: Could not parse cql : null</span> </div></div><p>You'll see frequent reference to a <strong>Layout Component</strong> in Tapestry documentation, but you won't find such a component in the <a shape="rect" href="component-reference.html">component reference</a>. The Layout component is a component <em>that you create</em> to provide common elements across all of your pages.</p><p>In traditional servlet development, you may be familiar with the use of a JSP include to include a banner across the top of your page and a copyright message across the bottom. In Tapestry, you <em>could</em> implement those recurring page elements as components (a banner component, a copyright component, etc.) and then add those components to every page.</p><p>But there's an even better way. Just create a layout component that provides the overall structure and r
 ecurring content for your pages:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Layout.tml (a template for a Layout component)</b></div><div class="codeContent panelContent pdl">
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;html xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_4.xsd&quot;&gt;
     &lt;head&gt;
         &lt;title&gt;My Nifty Web Application&lt;/title&gt;
     &lt;/head&gt;
@@ -143,7 +77,7 @@
 &lt;/html&gt;
 ]]></script>
 </div></div><p>In a real-world example, the two &lt;div&gt; elements above might contain the typical recurring content you'll see across the pages of a web application: banners, menus, login forms and so forth. Often these layout components get very complex ... in fact, in many applications the Layout component can grow to be as complex as any other component.</p><h2 id="LayoutComponent-UsingtheLayoutinaPage">Using the Layout in a Page</h2><p>To use your layout component, just have each page in your application <em>wrap itself</em> in the layout, like this:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Welcome.tml (the template for a page)</b></div><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;html t:type=&quot;layout&quot; xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_4.xsd&quot;&gt;
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;html t:type=&quot;layout&quot; xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_4.xsd&quot;&gt;
 
    &lt;h1&gt;Welcome to the Nifty Web Application!&lt;/h1&gt;
 
@@ -152,20 +86,14 @@
    &lt;/p&gt;
 &lt;/html&gt;
 ]]></script>
-</div></div><p>Note the "t:type="layout" part. That says, in effect, "wrap the layout component around my <em>content</em>".</p><p>The magic is in the &lt;t:body/&gt; element of the layout template; this will be replaced by each page's <em>content</em>, whatever that is.</p>    <div class="aui-message hint shadowed information-macro">
-                            <span class="aui-icon icon-hint">Icon</span>
-                <div class="message-content">
-                            <p>Remember that if your layout component includes a link to a resource such as an image or a stylesheet, you must use an <em>absolute</em> URL. The same component will be used for pages in many different folders, or with many different activation contexts, so relative URLs won't work. The best approach is to use the <a shape="rect" href="assets.html">context binding prefix</a>.</p>
-                    </div>
-    </div>
-<p>To keep our Welcome.tml page template relatively preview-able, we are using an &lt;html&gt; element and the t:type attribute to specify that it is a component. At render time, the page's &lt;html&gt; tag will be removed, and replaced with the content from the Layout.tml template (which conveniently starts with an &lt;html&gt; element). The &lt;t:body&gt; element in Layout.tml will be replaced with the page-specific content here: the &lt;h1&gt; and &lt;p&gt; tags.</p><p>Any page in the application that follows this pattern, using the Layout component, will have the same look and feel.</p><p>Layout is a regular component like other, with an ordinary component template. Like all component templates, it will be stored on the classpath (typically under src/main/resources).</p><p>Components must always have a Java class. But in this trivial example, the Layout component doesn't need any logic:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader 
 pdl" style="border-bottom-width: 1px;"><b>Layout.java</b></div><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Import(stylesheet=&quot;context:css/site.css&quot;)
+</div></div><p>Note the "t:type="layout" part. That says, in effect, "wrap the layout component around my <em>content</em>".</p><p>The magic is in the &lt;t:body/&gt; element of the layout template; this will be replaced by each page's <em>content</em>, whatever that is.</p><div class="confluence-information-macro confluence-information-macro-information"><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Remember that if your layout component includes a link to a resource such as an image or a stylesheet, you must use an <em>absolute</em> URL. The same component will be used for pages in many different folders, or with many different activation contexts, so relative URLs won't work. The best approach is to use the <a shape="rect" href="assets.html">context binding prefix</a>.</p></div></div><p>To keep our Welcome.tml page template relatively preview-able, we are using an &lt;html&gt; ele
 ment and the t:type attribute to specify that it is a component. At render time, the page's &lt;html&gt; tag will be removed, and replaced with the content from the Layout.tml template (which conveniently starts with an &lt;html&gt; element). The &lt;t:body&gt; element in Layout.tml will be replaced with the page-specific content here: the &lt;h1&gt; and &lt;p&gt; tags.</p><p>Any page in the application that follows this pattern, using the Layout component, will have the same look and feel.</p><p>Layout is a regular component like other, with an ordinary component template. Like all component templates, it will be stored on the classpath (typically under src/main/resources).</p><p>Components must always have a Java class. But in this trivial example, the Layout component doesn't need any logic:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Layout.java</b></div><div class="codeContent panelConten
 t pdl">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[@Import(stylesheet=&quot;context:css/site.css&quot;)
 public class Layout
 {
 }
 ]]></script>
 </div></div><p>We use the @<a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Import.html">Import</a> annotation (in 5.2 or later), as opposed to directly adding the &lt;link&gt; element to the template, for significant performance benefits <a shape="rect" href="assets.html">described elsewhere</a>. (For 5.0 and 5.1, use the deprecated @<a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/IncludeStylesheet.html">IncludeStyleSheet</a> annotation instead.)</p><p>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.</p><h2 id="LayoutComponent-NestedLayouts">Nested Layouts</h2><p>Layouts are really just o
 rdinary components, so they can be nested to any level needed. You can have, for example, a "CommonLayout" component that provides the peripheral elements for all your pages, and then a more specialized "AdminLayout" component that provides the layout only for the administrative pages, and make the AdminLayout component wrap itself in the CommonLayout component. So then the administrative pages would start with <code>&lt;html t:type="adminLayout" ...&gt;</code> and the other pages (and the AdminLayout component itself) would start with <code>&lt;html t:type="commonLayout" ...&gt;</code>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>AdminLayout.tml</b></div><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;html t:type=&quot;commonLayout&quot; xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_4.xsd&quot;&gt;
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;html t:type=&quot;commonLayout&quot; xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_4.xsd&quot;&gt;
 
     &lt;h1&gt;Administrative Functions&lt;/h1&gt;
 
@@ -174,7 +102,7 @@ public class Layout
 &lt;/html&gt;
 ]]></script>
 </div></div><h2 id="LayoutComponent-Amoreadvancedexample">A more advanced example</h2><p>Here's an example of a Layout component with a few more features. It has a "title" parameter, so that every page can pass in its own title to be rendered in the &lt;title&gt; tag <em>and</em> in an &lt;h1&gt; tag at the top of the HTML. There is also a "style" parameter that allows each page to pass in a block of CSS rules to be rendered in the &lt;head&gt; section of the page (useful for those few CSS rules that can't be put into a static CSS file). Notice the HTML5-style DOCTYPE declaration at the top, the charset definition as UTF-8, and the addition of an "alerts" component.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Layout.tml (a template for a Layout component)</b></div><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;!DOCTYPE html&gt;
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;!DOCTYPE html&gt;
 &lt;html xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_4.xsd&quot;&gt;
     &lt;head&gt;
         &lt;meta charset=&quot;UTF-8&quot; /&gt;
@@ -201,7 +129,7 @@ public class Layout
 &lt;/html&gt;
 ]]></script>
 </div></div><p>The <a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/Alerts.html">Alerts</a> component above is new in Tapestry 5.3; it 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.</p><p>The corresponding component class is still very simple, adding support for the "title" and "style" parameters:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Layout.java</b></div><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Import(stylesheet=&quot;context:css/site.css&quot;)
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[@Import(stylesheet=&quot;context:css/site.css&quot;)
 public class Layout
 {
     /** The page title, for the &lt;title&gt; element and the &lt;h1&gt; element. */
@@ -216,7 +144,7 @@ public class Layout
 }
 ]]></script>
 </div></div><p>Here's how you might use the above layout component for a UserList page:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>UserList.tml</b></div><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;html t:type=&quot;layout&quot; title=&quot;List of Users&quot;
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;html t:type=&quot;layout&quot; title=&quot;List of Users&quot;
     xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_4.xsd&quot;
     xmlns:p=&quot;tapestry:parameter&quot;&gt;
 &lt;p:style&gt;
@@ -230,7 +158,7 @@ public class Layout
 &lt;/html&gt;
 ]]></script>
 </div></div><p>The &lt;p:style&gt; element (and its contents) are passed to the layout component as a <code>style</code> parameter (a block parameter, in this case, so you must have the <code>xmlns:p="tapestry:parameter"</code> namespace declared, as above).</p><p>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"):</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>The rendered HTML</b></div><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;!DOCTYPE html&gt;
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;!DOCTYPE html&gt;
 &lt;html&gt;
     &lt;head&gt;
         &lt;meta charset=&quot;UTF-8&quot; /&gt;