[CONF] Apache Tapestry Documentation

2010-11-23 Thread confluence







Documentation
Page edited by Bob Harner


Comment:
Minor formatting  grammar


 Changes (14)
 



...
- [Tutorial] - [Frequently Asked Questions] 
- [TAPESTRY:Component Cheat Sheet] is -- a quick reference to common annotations and method names 
- [User Guide] is -- a collection of detailed references to the concepts behind Tapestry 
- [Cookbook] is -- a collection of tips and tricks for commonly occuring patterns in Tapestry 
- [Deployment Notes] -- a guide to deploying Tapestry on common application servers 
- [Developer Information] 
- [Refcard|http://refcardz.dzone.com/refcardz/apache-tapestry-50?oid=hom7948] -- a six page foldout guide to Tapestry 5.0 
 h2. Tapestry 5 Reference and API 
...
h2. Articles  
If you had a doubt, have any doubts, [Tapestry 5 for Nonbelievers|http://www.infoq.com/articles/tapestry5-intro] will demonstrate why you should choose Tapestry 5\! 
 [More articles|TAPESTRY:Articles]... 
...
h2. Blogs  
* [Tapestry Central|http://tapestryjava.blogspot.com/] is Howard Lewis Ships blog. As the creator of Tapestry, he provides a lot of valuable information on Tapestrys latest features and future directions. 
 
[Igor Drobiazkos|http://blog.tapestry5.de/] (Committer and PMC member) s blog contains a lot of fresh news on  Tapestry development, it will guide you through the most exciting part of  Tapestry. 
* [Igor Drobiazkos blog|http://blog.tapestry5.de/] contains a lot of fresh news on Tapestry development and will guide you through the most exciting part of  Tapestry.  Igor is a Tapestry Committer and PMC member. 
 [More blogs|TAPESTRY:Blogs] ... 
...
h2. Presentations  
* [JavaServer Faces 2.0 vs. Tapestry 5|http://jazoon.com/Portals/0/Content/slides/th_a7_1130-1220_drobiazko.pdf] : A Head-to-Head Comparison by Igor Drobiazko at Jazoon 2010 
 
* [Tapestry 5 : Java power, Scripting ease|http://www.parleys.com/#st=5sl=5id=1700] by Howard Lewis Ship at Devoxx 2090 2009 
 
* [More presentations|TAPESTRY:Presentations] ... 
 h2. Wiki  
[Communitys Wiki|http://wiki.apache.org/tapestry/FrontPage] contains many informations on different concrete web applications use cases 
[Communitys Wiki|http://wiki.apache.org/tapestry/FrontPage] contains a lot of information on different concrete web application use cases. 

Full Content



Overview


	Introduction
	Getting Started
	Tutorial
	Frequently Asked Questions
	Component Cheat Sheet  a quick reference to common annotations and method names
	User Guide  a collection of detailed references to the concepts behind Tapestry
	Cookbook  a collection of tips and tricks for commonly occuring patterns in Tapestry
	Deployment Notes  a guide to deploying Tapestry on common application servers
	Developer Information
	Refcard  a six page foldout guide to Tapestry 5.0



Tapestry 5 Reference and API


	Current stable release 5.1.0.5
	
		API (Javadoc)
		Component Reference
		Release Notes
	
	




	Previous stable release 5.0.18
	
		API (Javadoc)
		Component Reference
		Release Notes
	
	




	Current beta release 5.2.4
	
		API (Javadoc)
		Component Reference
		Release Notes
	
	



Articles

If you have any doubts, Tapestry 5 for Nonbelievers will demonstrate why you should choose Tapestry 5

More articles...

Blogs


	Tapestry Central is Howard Lewis Ship's blog. As the creator of Tapestry, he provides a lot of valuable information on Tapestry's latest features and future directions.




	Igor Drobiazko's blog contains a lot of fresh news on Tapestry development and will guide you through the most exciting part of  Tapestry.  Igor is a Tapestry Committer and PMC member.



More blogs ...

Books

More books ...

Presentations


	JavaServer Faces 2.0 vs. Tapestry 5: A Head-to-Head Comparison by Igor Drobiazko at Jazoon 2010




	Tapestry 5 : Java power, Scripting ease by Howard Lewis Ship at Devoxx 2009




	More presentations ...



Wiki

Community's Wiki contains a lot of information on different concrete web application use cases.



Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry IoC - injection

2010-11-23 Thread confluence







IoC - injection
Page edited by Howard M. Lewis Ship


 Changes (22)
 



...
Injection is triggered in a number of ways:  
* A field in a component class, autobuilt object, or service implementation class the [Inject|../apidocs/org/apache/tapestry5/ioc/annotations/Inject.html] [Inject|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Inject.html] annotation. 
* A method parameter to a service builder method, a decorator method, or a contribute method (in a Tapestry IoC module class). * A constructor parameter to an autobuilt object, or a service implementation class. 
* Any of the above with an [InjectService|../apidocs/org/apache/tapestry5/ioc/annotations/InjectService.html] [InjectService|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/InjectService.html] annotation. 
Injection also covers a related matter: providing special resources to a service or component. For a service, the services id (as a string) or extensible configuration (as a Collection, List or Map) may be provided. For a component, the components id, locale, message catalog, or component resources may be provided.  
...
 * org.slf4j.Logger The Logger of the service being constructed (or the logger of the Module class being instantiated). 
* [ObjectLocator|../apidocs/org/apache/tapestry5/ioc/ObjectLocator.html] [ObjectLocator|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/ObjectLocator.html] For contribute methods, used to locate additional objects. * [ServiceResources|../apidocs/org/apache/tapestry5/ioc/ServiceResources.html] [ServiceResources|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/ServiceResources.html] For service builder methods, an extended version of ObjectLocator. Class The service interface type. * [OperationTracker|../apidocs/org/apache/tapestry5/ioc/OperationTracker.html] [OperationTracker|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/OperationTracker.html] Used to track deeply nested operations so that errors can be reported sensibly. 
* Object, or service interface type Passed to decorator methods.  * Collection, List, Map Assembled service configurations passed to service builder methods (or service class constructors). * Configuration, OrderedConfiguration, MappedConfiguration Configuration passed to contribute methods, to build service configurations.If field type does not match any of the available resource types, or the Inject annotation is present, logic continues to the next step.  
Injection of resources into fields is triggered by the presence of the [InjectResource|../apidocs/org/apache/tapestry5/ioc/annotations/InjectResource.html] [InjectResource|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/InjectResource.html] annotation, whereas injection of resources into parameters occurs when the Inject or InjectService annotation is _not_ present. These rules are slightly tricky, which reflects a desire to avoid any annotations except when needed, and the fact that field injection came much later than parameter injection. 
 h2. Service Lookup by Type and Annotations 
...
First, it generates a set of services whose service interface is compatible with the injection type. This is based on assignability.  
If the [Local|../apidocs/org/apache/tapestry5/ioc/annotations/Local.html] [Local|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Local.html] annotation is present, then services not from the module containing the service being constructed will be eliminated. 
 Tapestry then works through the known marker annotations. For each marker annotation that is present at the point of annotation, Tapestry eliminates services which do not have the marker. Thus, if multiple marker annotations are present, the final service must have _all of them_. 
...
h2. MasterObjectProvider Lookup  
This is the point at which Tapestrys extensibility comes into play. MasterObjectProvider is a service, with a configuration of [ObjectProvider|../apidocs/org/apache/tapestry5/ioc/ObjectProvider.html]s. [ObjectProvider|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/ObjectProvider.html]s. 
 The MasterObjectProvider is also the point at which Tapestrys IoC layer injection, and Tapestrys component injection, unite. 
...
h3. Value ObjectProvider  
Checks for the presence of the [Value|../apidocs/org/apache/tapestry5/ioc/annotations/Value.html] [Value|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Value.html] annotation. If present, 

[CONF] Apache Tapestry IoC - injection

2010-11-23 Thread confluence







IoC - injection
Page edited by Howard M. Lewis Ship


 Changes (0)
 



...

Full Content

Injection in Detail

Injection in Tapestry IoC can be a complicated subject for a number of reasons:


	Injection can occur in many places: on fields, and on parameters to methods and constructors of certain objects.
	Parts of Injection are themselves defined in terms of Tapestry IoC services, many of which are extensible.



Despite this, injection generally Just Works: most of the time, you want Tapestry to inject a service, and only a single service implements the service interface.

This document discusses what to do when you hit a case that doesn't Just Work, or when you want to extend the injection logic in some way.

Some aspects of this discussion reflect Tapestry IoC used within a Tapestry web application: the tapestry-core module makes some extensions to injection.

Injection Triggers

Injection is triggered in a number of ways:


	A field in a component class, autobuilt object, or service implementation class the Inject annotation.
	A method parameter to a service builder method, a decorator method, or a contribute method (in a Tapestry IoC module class).
	A constructor parameter to an autobuilt object, or a service implementation class.
	Any of the above with an InjectService annotation.
Injection also covers a related matter: providing special resources to a service or component. For a service, the service's id (as a string) or extensible configuration (as a Collection, List or Map) may be provided. For a component, the component's id, locale, message catalog, or component resources may be provided.



Standard Injection Processing

This section describes standard injection, which applies at the IoC layer: autobuild objects and service implementations. The steps for injection into Tapestry components are slightly different and are covered later.

So a the point of injection, Tapestry has identified a field or parameter that should be injected. At this point, Tapestry knows the following:


	The field name (if field injection). The parameter name is not available.
	The field or parameter type, as a Java class. In many cases, this will be enough to identify what object shall be injected.
	Any additional annotations on the field or parameter.
Tapestry proceeds with this information.



Check for InjectService

Tapestry checks first for the InjectService annotation. The value of this annotation is the service id to inject. When InjectService is present at the point of injection, that process is done, though it can fail if the service id indicated does not exist, or if the service's interface is not compatible with the field's type.

Check for service resources

This step applies only to IoC layer injection (not to injection into components).

When the Inject annotation is not present at the point of injection, Tapestry checks to see if a resource can be injected. When the Inject annotation is present, this step is skipped (this is necessary when the object to be injected has a type that conflicts with a resource type, such as List or Class).


	org.slf4j.Logger The Logger of the service being constructed (or the logger of the Module class being instantiated).
	ObjectLocator For contribute methods, used to locate additional objects.
	ServiceResources For service builder methods, an extended version of ObjectLocator. Class The service interface type.
	OperationTracker Used to track deeply nested operations so that errors can be reported sensibly.
	Object, or service interface type Passed to decorator methods.
	Collection, List, Map Assembled service configurations passed to service builder methods (or service class constructors).
	Configuration, OrderedConfiguration, MappedConfiguration Configuration passed to contribute methods, to build service configurations.If field type does not match any of the available resource types, or the Inject annotation is present, logic continues to the next step.



Injection of resources into fields is triggered by the presence of the InjectResource annotation, whereas injection of resources into parameters occurs when the Inject or InjectService annotation is not present. These rules are slightly tricky, which reflects a desire to avoid any annotations except when needed, and the fact that field injection came much later than parameter injection.

Service Lookup by Type and Annotations

Tapestry attempts to find a matching service.

First, it generates a set of services whose service interface is compatible with the injection type. This is based on assignability.

If the Local annotation is present, then services not from the module containing the service being constructed will be eliminated.

Tapestry then works through the known marker annotations. For each marker annotation that is 

[CONF] Apache Tapestry IoC

2010-11-23 Thread confluence







IoC
Page edited by Howard M. Lewis Ship


 Changes (5)
 



...
* Although Spring allows beans to be intercepted, it does so in the form of a new bean, leaving the un-intercepted bean visible (and subject to misuse). Tapestry IoC wraps the service inside interceptors, preventing unintercepted access to the core service implementation. * Springs XML configuration files are quite verbose. This has improved with Spring 2.0, but still far more verbose that T5 IoC module classes. 
* Spring has a simple map/list/value configuration scheme, but it is not distributed; it is part of a single bean definition.  
* Spring has a simple map/list/value configuration scheme, but it is not distributed; it is part of a single bean definition. Tapestry 5 IoC allows a service configuration to be assembled from multiple modules. This is very important for seamless extensibility of the framework, with zero configuration (just drop the module into the classpath and everything hooks together). 
 
h2. Why Not HiveMind?  
...
h1. Overview  
The Tapestry IoC container takes over all the plumbing necessary for a highly scalable, extensible, thread-safe, testable application. Please see the [overview|#overview.html] [main Tapestry IoC ovcerview|TAPESTRY:IoC - overview] for more details. 
 h1. Terminology 
...
Services are identified by a unique id. Typically, a service id matches the unqualified name of the service interface, but this is simply a convention.  
{note} The evolution of the Tapestry IoC is to eventually eliminate service ids and work totally in terms of service interfaces and marker annotations. {note}  
Services are aggregated into *modules*:  
...

Full Content

Tapestry Inversion of Control Container

The inner construction of the Tapestry framework is based on inversion of control, a design approach that allows a working system to be fabricated from many small, easily testable pieces.

An additional benefit of using IoC (Inversion of Control) is that, by breaking a complex system into small pieces, it becomes easier to modify and extend the system, by overriding or replacing selected parts of the system.

The use of IoC in Tapestry represents an evolution from Tapestry 3 to Tapestry 4 to Tapestry 5. Tapestry 3 did not use IoC, though it included some weaker mechanisms, such as extensions, that served a similar purpose. To make large scale changes to the behavior of Tapestry 3 required subclassing key classes and overriding methods.

Tapestry 4 introduced the use of the Apache HiveMind IoC container. In fact, the HiveMind project was created specifically for use as the IoC container for Tapestry 4. Tapestry 4 has met its goals for extensibility and configurability, largely because of HiveMind's flexibility.

Tapestry 5 extends on this, replacing HiveMind with a new container specifically build for Tapestry 5, designed for greater ease of use, expressiveness and performance. HiveMind itself has been subsequently shelved; T5 IoC can be considered a streamlined and improved HiveMind. And T5 IoC can be used separately from the rest of Tapestry!

Why Not Spring?

Spring is the most successful IoC container project. The Spring project combines a very good IoC container, integrated AspectJ support, and a large number of libraries built on top of the container. Spring is an excellent application container, but lacks a number of features necessary for a framework container:


	Spring beans can be wired together by name (or id), but it is not possible to introduce additional naming abstractions. Tapestry 4's "infrastructure:" abstraction was the key to allowing easy spot overrides of internal Tapestry services without having to duplicate the large web of interrelated services (nearly 200 in Tapestry 4.0).
	Although Spring allows beans to be intercepted, it does so in the form of a new bean, leaving the un-intercepted bean visible (and subject to misuse). Tapestry IoC "wraps" the service inside interceptors, preventing unintercepted access to the core service implementation.
	Spring's XML configuration files are quite verbose. This has improved with Spring 2.0, but still far more verbose that T5 IoC module classes.
	Spring has a simple map/list/value configuration scheme, but it is not distributed; it is part of a single bean definition.
Tapestry 5 IoC allows a service configuration to be assembled from multiple modules. This is very important for seamless extensibility of the framework, with zero configuration (just drop the module into the classpath and everything hooks together).



Why Not HiveMind?

The difficulty of managing the release schedules of two complex frameworks 

[CONF] Apache Tapestry Injection

2010-11-23 Thread confluence







Injection
Page edited by Christophe Cordenier


Comment:
Fix broken links


 Changes (7)
 



h1. Injection with Components  
A key concept in Tapestry is the use of _injection_. The [Tapestry IoC container|../../tapestry-ioc/index.html] makes use of one form of injection, via parameters to service builder methods. 
 For components, Tapestry takes a completely different tack: injection directly into instance variables. 
...
h1. Inject Annotation  
The [Inject annotation|../apidocs/org/apache/tapestry5/ioc/annotations/Inject.html] annotation|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Inject.html] is used to identify fields that will contain injected services and other resources. 
 Tapestry allows for two kinds of injection: 
...
h2. Asset Injection  
When the [Path|../apidocs/org/apache/tapestry5/annotations/Path.html] [Path|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Path.html] annotation is also present, then the injected value (relative to the component) will be a localized [asset|#assets.html]. 
 Symbols in the annotation value are expanded. 
...
h2. Block Injection  
For field type [Block|../apidocs/org/apache/tapestry5/Block.html], [Block|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/Block.html], the value of the Inject annotation is the id of the [block element|#templates.html] within the components template. Normally, the id of the block is determined from the field name (after stripping out leading _ and $ characters). Where that is not appropriate, an [Id|../apidocs/org/apache/tapestry5/annotations/Id.html] [Id|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Id.html] annotation can be supplied: 
 {code:java} 
...
For a particular set of field types, Tapestry will inject a _resource_ related to the component, such as its Locale.  
A very common example occurs when a component needs access to its [resources|../apidocs/org/apache/tapestry5/ComponentResources.html]. [resources|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ComponentResources.html]. The component can define a field of the appropriate type and use the Inject annotation without a value: 
 {code:java} 
...
 java.lang.String The complete id of the component, which incorporates the complete class name of the containing page and the nested id of the component within the page. java.util.Locale The locale for the component (all components within a page use the same locale). org.slf4j.Logger A Logger instance configured for the component, based on the components class name. [SLF4J|http://www.slf4j.org/] is a wrapper around Log4J or other logging toolkits. org.apache.tapestry5.ComponentResources The resources for the component, often used to generate links related to the component. org.apache.tapestry5.ioc.Messages The component message catalog for the component, from which [localized|#localization.html] messages can be generated.h1. Explicit Service Injection  
Here, a specific object is requested. A [Service|../apidocs/org/apache/tapestry5/annotations/Service.html] [Service|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Service.html] annotation is used to identify the service name. 
 Example: 
...
h1. Defining New Injection Logic  
Annonymous injection is controlled by the [InjectionProvider|../apidocs/org/apache/tapestry5/services/InjectionProvider.html] [InjectionProvider|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/InjectionProvider.html] service. The configuration for this service is a [chain of command|../../tapestry-ioc/command.html] command|IoC - command] for handling component injections. 

Full Content

Injection with Components

A key concept in Tapestry is the use of injection. The Tapestry IoC container makes use of one form of injection, via parameters to service builder methods.

For components, Tapestry takes a completely different tack: injection directly into instance variables.

Inject Annotation

The Inject annotation is used to identify fields that will contain injected services and other resources.

Tapestry allows for two kinds of injection:


	Explicit injection, where the particular service to be injected is specified.
	Default injection, where Tapestry determines the object to inject into the field based on its type.
In both cases, the field is transformed into a read only value. As elsewhere in Tapestry, this transformation 

[CONF] Apache Tapestry Request Processing

2010-11-23 Thread confluence







Request Processing
Page edited by Christophe Cordenier


Comment:
Fix broken links


 Changes (10)
 



...
Understanding the request processing pipeline is very important, as it is one of the chief extension points for Tapestry.  
Much of the early stages of processing are in the form of extensible [pipelines|../tapestry-ioc/pipeline.html]. [pipelines|IoC - pipeline]. 
 h1. Tapestry Filter  
All incoming requests originate with the TapestryFilter, which is configured inside the applications [web.xml|#conf.html]. [web.xml|Configuration]. 
 The TapestryFilter is responsible for a number of startup and initialization functions.  
When it receives a request, the TapestryFilter obtains the [HttpServletRequestHandler|../apidocs/org/apache/tapestry5/services/HttpServletRequestHandler.html] [HttpServletRequestHandler|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/HttpServletRequestHandler.html] service, and invokes its service() method. 
 h1. HttpServletRequestHandler Pipeline  
This pipeline performs initial processing of the request. It can be extended by contributing a [HttpServletRequestFilter|../apidocs/org/apache/tapestry5/services/HttpServletRequestFilter.html] [HttpServletRequestFilter|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/HttpServletRequestFilter.html] into the HttpServletRequestHandler services configuration. 
 Tapestry does not contribute any filters into this pipeline of its own 
...
The terminator for the pipeline does two things:  
* It stores the request and response into the [RequestGlobals|../apidocs/org/apache/tapestry5/services/RequestGlobals.html] [RequestGlobals|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/RequestGlobals.html] service. This is a threaded service that stores per-thread/per-request information. 
* It wraps the request and response as a [Request|../apidocs/org/apache/tapestry5/services/Request.html] [Request|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/Request.html] and [Response|../apidocs/org/apache/tapestry5/services/Response.html], [Response|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/Response.html], and passes them into the [RequestHandler|../apidocs/org/apache/tapestry5/services/RequestHandler.html] [RequestHandler|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/RequestHandler.html] pipeline. 
Primarily, this exists to bridge from the Servlet API objects to the corresponding Tapestry objects. This is the basis for the planned portlet integration for Tapestry.  
...
* Localization identifies the [locale for the user|#localization.html]. * StaticFiles checks for URLs that are for static files (files that exist inside the web context) and aborts the request, so that the servlet container can handle the reuest normally. 
* ErrorFilter catches uncaught exceptions from the lower levels of Tapestry and presents the exception report page. This involves the [RequestExceptionHandler|../apidocs/org/apache/tapestry5/services/RequestExceptionHandler.html] [RequestExceptionHandler|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/RequestExceptionHandler.html] service, which is responsible for initializing and rendering the [core/ExceptionReport|../apidocs/org/apache/tapestry5/corelib/pages/ExceptionReport.html] [core/ExceptionReport|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/pages/ExceptionReport.html] page. 
The terminator for this pipeline stores the Request and the Response into RequestGlobals, then requests that the [MasterDispatcher|../apidocs/org/apache/tapestry5/services/Dispatcher.html] [MasterDispatcher|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/Dispatcher.html] service figure out how to handle the request (if it is, indeed, a Tapestry request). 
 h1. Master Dispatcher Service 
...
In cases where the event type is not the default, action, it will appear between the nested component id and the event context, preceded by a colon. Example: /example/foo.bar:magic/99 would trigger an event of type magic. This is not common in the vanilla Tapestry framework, but will likely be more common as Ajax features (which would not use the normal request logic) are implemented.  
The response from a component action request is typically, but not universally, used to send a redirect to the client; the redirect URL is a page render URL to display the response to the event. This is detailed under [page navigation|#pagenav.html]. 

[CONF] Apache Tapestry Environmental Services

2010-11-23 Thread confluence







Environmental Services
Page edited by Christophe Cordenier


Comment:
Fix broken links


 Changes (5)
 



...
Environmental services are often a conduit of communication between an outer component and the components it encloses.  
An example of this is form support; the [Form|../tapestry-core/ref/org/apache/tapestry5/corelib/components/Form.html] [Form|http://tapestry.apache.org/current/tapestry-core/ref/org/apache/tapestry5/corelib/components/Form.html] component creates an environmental of type [FormSupport|../apidocs/org/apache/tapestry5/services/FormSupport.html]. [FormSupport|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/FormSupport.html]. The FormSupport interface allows enclosed components to participate in both the rendering of the Form and the Forms eventual submission. This is how control names and client-side ids are determined, how fields register callbacks so that they can process their part of the submission, and how fields hook themselves to client-side validation. 
 h1. Using the @Environmental annotation  
The [Environmental|../apidocs/org/apache/tapestry5/annotations/Environmental.html] [Environmental|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Environmental.html] annotation is used to dynamically connect to a Environmental service provided by an enclosing component. 
 
A very common Environmental is [RenderSupport|../apidocs/org/apache/tapestry5/RenderSupport.html], [RenderSupport|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/RenderSupport.html], used when generating [client-side _javascript_|#ajax.html]. _javascript_|Ajax  _javascript_]. 
 {code:java} 
...
Environmental services are, by their nature, per-thread (and therefore per-request).  
Accessing an environmental field causes a lookup, by type, against the [Environment|../apidocs/org/apache/tapestry5/services/Environment.html] [Environment|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/Environment.html] service. 
 Normally, an environmental of the specified type must be available in the Environment, or an exception is thrown when accessing the field. 
...
Not all environmentals are pushed into the Environment by components.  
A number of environmentals are initialized as part of page rendering, even before the first component starts to render. This initialization is accomplished with [MarkupRendererFilter|../apidocs/org/apache/tapestry5/services/MarkupRendererFilter.html] [MarkupRendererFilter|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/MarkupRendererFilter.html] contributions to the [MarkupRenderer|../apidocs/org/apache/tapestry5/service/MarkupRenderer.html] [MarkupRenderer|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/service/MarkupRenderer.html] service. 
 h1. Accessing Environmentals in Services 
...

Full Content

Environmental Services

Environmental services represent yet another, distinct form of injection.

Unlike service injection (injection via a service implementation's constructor) or normal component injection (directly into component fields, via the @Inject annotation) where the injected value is always the same, with environmental services, the injected value is very late bound and dynamic.

Environmental services are often a conduit of communication between an outer component and the components it encloses.

An example of this is form support; the Form component creates an environmental of type FormSupport. The FormSupport interface allows enclosed components to participate in both the rendering of the Form and the Form's eventual submission. This is how control names and client-side ids are determined, how fields register callbacks so that they can process their part of the submission, and how fields hook themselves to client-side validation.

Using the @Environmental annotation

The Environmental annotation is used to dynamically connect to a Environmental service provided by an enclosing component.

A very common Environmental is RenderSupport, used when generating client-side _javascript_.




  @Inject @Path("${tapestry.scriptaculous}/dragdrop.js")
  private Asset dragDropLibrary;

  @Environmental
  private RenderSupport renderSupport;

  void setupRender()
  {
renderSupport.addScriptLink(dragDropLibrary);
  }




Environmental services are, by their nature, per-thread (and therefore per-request).

Accessing an environmental field causes a lookup, by type, against the Environment service.

Normally, an environmental of the specified type must be available 

[CONF] Apache Tapestry IoC cookbook - basics

2010-11-23 Thread confluence







IoC cookbook - basics
Page edited by Christophe Cordenier


Comment:
Fix broken links


 Changes (6)
 



...
The simplest services donapos;t have any special configuration or dependencies. They are defined as services so that they can be shared.  
For example, the [PropertyAccess|../../apidocs/org/apache/tapestry5/ioc/services/PropertyAccess.html] [PropertyAccess|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/services/PropertyAccess.html] service is used in multiple places around the framework to access properties of objects (its a wrapper around the Java Beans Introspector and a bit of reflection). This is defined in the [TapestryIOCModule|../../apidocs/org/apache/tapestry5/ioc/services/TapestryIOCModule.html]. [TapestryIOCModule|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/services/TapestryIOCModule.html]. 
 Itapos;s useful to share PropertyAccess, because it does a lot of useful caching internally. 
...
  }{code}  
This example includes [ExceptionAnalyzer|../../apidocs/org/apache/tapestry5/ioc/services/ExceptionAnalyzer.html], [ExceptionAnalyzer|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/services/ExceptionAnalyzer.html], because it has a dependency on PropertyAccess: 
 {code|borderStyle=solid} 
...
A service builder method is a method of a Module, prefixed with the word quot;buildquot;. This defines a service, and dependency injection occurs on the parameters of the service builder method.  
The Tapestry web framework includes the concept of an quot;assetquot;: a resource that may be inside a web application, or packaged inside a JAR. Assets are represented as the type [Asset|../../apidcos/org/apache/tapestry5/Asset.html]. [Asset|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/Asset.html]. 
 
In fact, there are different implementations of this class: one for context resources (part of the web application), the other for classpath resources (packaged inside a JAR). The Asset instances are created via [AssetFactory|../../apidocs/org/apache/tapesty/services/AssetFactory.html] [AssetFactory|http://tapestry.apache.org/current/apidocs/org/apache/tapesty/services/AssetFactory.html] services. 
 
Tapestry defines two such services, in the [TapestryModule|../../apidocs/org/apache/tapestry5/services/TapestryModule.html]. [TapestryModule|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/TapestryModule.html]. 
 {code|borderStyle=solid} 
...
Whatapos;s important is that the services are differentiated not just in terms of their id (which is defined by the name of the method, after stripping off quot;buildquot;), but in terms of their _marker annotation_.  
The [Marker|../../apidocs/org/apache/tapestry5/ioc/annotations/Marker.html] [Marker|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Marker.html] annotation provides the discriminator. When the service type is supplemented with the ClasspathProvider annotation, the ClasspathAssetFactory is injected. When the service type is supplemented with the ContextProvider annotation, the ContextAssetFactory is injected. 
 Hereapos;s an example. Again, weapos;ve jumped the gun with this _service contributor method_ (weapos;ll get into the why and how of these later), but you can see how Tapestry is figuring out which service to inject based on the presence of those annotations: 
...

Full Content

Basic Services and Injection

A good part of the basics is convention: what to name your classes, what packages to put them in and so forth.

In many cases, these conventions are just a little stronger: you may have to do some amount of extra configuration if you choose to go your own way.

Getting Started

Like anything else, you want to choose a package for your application, such as org.example.myapp.

By convention, services go in a package named services.

Module classes are suffixed with Module.

Thus, you might start with a module class org.example.myapp.services.MyAppModule.

Simple Services

The simplest services dont have any special configuration or dependencies. They are defined as services so that they can be shared.

For example, the PropertyAccess service is used in multiple places around the framework to access properties of objects (its a wrapper around the Java Beans Introspector and a bit of reflection). This is defined in the TapestryIOCModule.

Its useful to share PropertyAccess, because it does a lot of useful caching internally.

The PropertyAccess service is defined inside 

[CONF] Apache Tapestry IoC - strategy

2010-11-23 Thread confluence







IoC - strategy
Page edited by Christophe Cordenier


Comment:
Fix broken links


 Changes (2)
 



...
Another of the Gang Of Four patterns, the strategy pattern as implemented in Tapestry IoC is a kind of late binding.  
The idea is that _adapters_ for objects are accessed based on the _actual type_ of an object. These adapters supply additional functionality. The adapters are located using an [StrategyRegistry|../apidocs/org/apache/tapestry5/util/StrategyRegistry.html]. [StrategyRegistry|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/util/StrategyRegistry.html]. 
 The lookup of adapters is based on an inheritance search; thus providing an adapter for type java.util.Map will match any object that implements the Map interface. The inheritance search works its way up the class hierarchy looking for a matching registration. If nothing is found, then all the interfaces directly or indirectly implemented by the selector class are checked. java.lang.Object is always the final match. 
...
As a special case, the value null is search for as if it was an instance of the class void.  
The [StrategyBuilder|../apidocs/org/apache/tapestry5/ioc/services/StrategyBuilder.html] [StrategyBuilder|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/services/StrategyBuilder.html] service creates a service implementation around a strategy registry. 
 {code:java} 
...

Full Content

Strategy Pattern

Another of the Gang Of Four patterns, the strategy pattern as implemented in Tapestry IoC is a kind of late binding.

The idea is that adapters for objects are accessed based on the actual type of an object. These adapters supply additional functionality. The adapters are located using an StrategyRegistry.

The lookup of adapters is based on an inheritance search; thus providing an adapter for type java.util.Map will match any object that implements the Map interface. The inheritance search works its way up the class hierarchy looking for a matching registration. If nothing is found, then all the interfaces directly or indirectly implemented by the selector class are checked. java.lang.Object is always the final match.

A runtime exception is thrown if no match can be found.

As a special case, the value null is search for as if it was an instance of the class void.

The StrategyBuilder service creates a service implementation around a strategy registry.



public interface StrategyBuilder
{
S S build(StrategyRegistryS registry);
}


For a given interface (and matching StrategyRegistry), a service implementation is created. The service interface is determined from the strategy registry.

The first parameter of each method is the selector. Its type is used to locate an adapter.

The corresponding method of the adapter is then invoked, passing all parameters.

Every method of the service interface should take at least one parameter. Generally, such interfaces have only one or two methods.

Example

You will usually have a service configuration for defining the adapter registry.

You convert the configuration into a StrategyRegistry, and use that to build the final service:



  public static MyStrategyService build(MapClass, MyStrategyService configuration,
@InjectService("StrategyBuilder")
StrategyBuilder builder)
  {
 StategyRegistryMyStrategyService registry = StrategyRegistry.newInstance(MyStrategyService.class, configuration);
  
 return builder.build(registry);
  }





Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry Component Mixins

2010-11-23 Thread confluence







Component Mixins
Page edited by Christophe Cordenier


Comment:
Fix broken links


 Changes (5)
 



...
An instance mixin is a mixin applied to a specific _instance_ of a component. This can be done in the [component template|#templates.html] with the mixins attribute of the comp element. This is a comma-separated list of mixin names.  
Alternately, when the [Component annotation|../apidocs/org/apache/tapestry5/annotations/Component.html] annotation|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Component.html] is used to define the component type, you may specify the mixins in two ways: 
 
* The [Mixins annotation|../apidocs/org/apache/tapestry5/annotations/Mixins.html] annotation|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Mixins.html] allows a list of mixin names to be specified. 
* The [MixinClasses annotation|../apidocs/org/apache/tapestry5/annotations/MixinClasses.html] annotation|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/MixinClasses.html] allows a set of mixin class to be specified directly. 
The former is often less verbose, and allows core mixins to be overridden with application-specific mixins. The later format is more specific and more friendly in terms of refactoring (renaming a mixin class will rename the entry in the MixinClasses annotation as well).  
...
h1. Implementation Mixins  
Implementation mixins, mixins which apply to all isntances of a component, are added using the [Mixin annotation|../apidocs/org/apache/tapestry5/annotations/Mixin.html]. annotation|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Mixin.html]. This annotation defines a field that will containg the mixin instance. 
 {code:java} 
...
All mixins for a component execute their render phase methods _before_ the components render phase methods for most phases. However, in the later phases (AfterRender, CleanupRender) the order of executing is reversed.  
Exception: Mixins whose class is annotated with [MixinAfter|../apidocs/org/apache/tapestry5/annotations/MixinAfter.html] [MixinAfter|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/MixinAfter.html] are ordered _after_ the component, not before. 

Full Content

Component Mixins

Tapestry 5 includes a radical feature, component mixins. Component mixins are a tricky concept; it basically allows a true component to be mixed together with special limited components called mixins. The component plus its mixins are represented as just a single tag in the component template, but all the behavior of all the elements.

The planned uses for this are to add validation to user input fields, or to add Ajax effects and behaviors to all sorts of components.

You can think of a mixin as a kind of mashup for a component; it combines the behavior of the component with the behavior of the mixin, and bundles it all in one place.

Mixins are used in two different scenarios: Instance mixins and Implementation mixins.

Mixin Classes

Mixin classes are stored in a mixins sub-package, below the application (or library) root package. This parallels where component and page classes are stored.

Other than that, mixin classes are exactly the same as any other component class.

Mixin Limitations

Currently, mixins are allowed to do anything a component can do, including parameters, render phase methods.

Mixins may not have a template. They integrate with the component strictly in terms of invoking render phase methods.

Mixins may have persistent fields, but currently, this is not implemented perfectly (there is a potential for a name clash between a mixin and the component or another mixin). Use persistent fields with mixins with care ... or better yet, delegate persistence to the container using parameters.

Mixins may not, themselves, have mixins.

Instance Mixins

An instance mixin is a mixin applied to a specific instance of a component. This can be done in the component template with the mixins attribute of the comp element. This is a comma-separated list of mixin names.

Alternately, when the Component annotation is used to define the component type, you may specify the mixins in two ways:


	The Mixins annotation allows a list of mixin names to be specified.
	The MixinClasses annotation allows a set of mixin class to be specified directly.
The former is often less verbose, and allows core mixins to be overridden with application-specific mixins. The later format is more specific and more friendly in terms of refactoring (renaming a mixin class will rename the entry in the 

[CONF] Apache Tapestry Persistent Page Data

2010-11-23 Thread confluence







Persistent Page Data
Page edited by Christophe Cordenier


Comment:
Fix broken links


 Changes (6)
 



...
However, you often want to store some persistent data on a _single_ page, and have access to it in later requests. Long term storage of data should go in a database of some form, but server-side state for the duration of the as users interaction with the application should go in the HttpSession (though Tapestry provides a few other options as well).  
*Note:* To store values that may be accessed across multiple pages, uses a [session state object|#appstate.html]. object|Persistent state]. 
 
Making a field persistent is accomplished with the [Persist annotation|../apidocs/org/apache/tapestry5/annotations/Persist.html]. annotation|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Persist.html]. Again, this does _not_ refer to database persistence, it refers to session persistance. 
 This annotation is applied to private instance fields of components. 
...
By default the value for the Persist annotation is the empty string. When this is true, then the actual strategy to be used is determined by a search up the component hiearchy.  
For each component, the meta-data property {{tapestry.persistence-strategy}} is checked. This can be specified using the [Meta|../apidocs/org/apache/tapestry5/annotations/Meta.html] [Meta|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Meta.html] annotation. 
 If the value is non-blank, then that strategy is used. This allows a component to control the persistence strategy used inside any sub-components (that dont explicitly use a different strategy). 
...
Tapestry knows that Javas String, Number and Boolean classes are immutable. Immutable objects do not require a re-store into the session.  
You can mark your own session objects as immutable using the [ImmutableSessionPersistedObject|../apidocs//org/apache/tapestry5/annotations/ImmutableSessionPersistedObject.html] [ImmutableSessionPersistedObject|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/ImmutableSessionPersistedObject.html] annotation. 
 h2. OptimizedSessionPersistedObject  
The [OptimizedSessionPersistedObject|../apidocs/org/apache/tapestry5/OptimizedSessionPersistedObject] [OptimizedSessionPersistedObject|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/OptimizedSessionPersistedObject] interface allows an object to control this behavior. An object with this interface can track when its mutable state changes. Typically, you should extend from the [BaseOptimizedSessionPersistedObject|../apidocs/org/apache/tapestry5/BaseOptimizedSessionPersistedObject.html] [BaseOptimizedSessionPersistedObject|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/BaseOptimizedSessionPersistedObject.html] base class. 
 h2. SessionPersistedObjectAnalyzer  
The [SessionPersistedObjectAnalyzer|../apidocs/org/apache/tapestry5/services/SessionPersistedObjectAnalyzer.html] [SessionPersistedObjectAnalyzer|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/SessionPersistedObjectAnalyzer.html] service is ultimately responsible for determining whether a session persisted object is dirty or not (dirty meaning in need of a restore into the session). This is an extensible service where new strategies, for new classes, can be introduced. 

Full Content

Persistent Page Data

Most instance variables in Tapestry are automatically cleared at the end of each request.

This is important, as it pertains to how Tapestry pages are pooled and shared, over time, by many users.

However, you often want to store some persistent data on a single page, and have access to it in later requests. Long term storage of data should go in a database of some form, but server-side state for the duration of the as user's interaction with the application should go in the HttpSession (though Tapestry provides a few other options as well).

Note: To store values that may be accessed across multiple pages, uses a session state object.

Making a field persistent is accomplished with the Persist annotation. Again, this does not refer to database persistence, it refers to session persistance.

This annotation is applied to private instance fields of components.



  @Persist
  private int value;



Annotated fields will store their state between requests. Generally, speaking, this means that the value is stored into the session (but other approaches are possible).

Whenever you make a change to a persistent field, its value is stored.

On later 

[CONF] Apache Tapestry IoC - advice

2010-11-23 Thread confluence







IoC - advice
Page edited by Howard M. Lewis Ship


 Changes (30)
 



h1. Service Advisors  
Service advice represents a powerful meta-programming facility available to services. In fact, it is a kind of limited Aspect Oriented Programming. 
 
Service advice allows you to intercept method invocations on your services; you have the abillity to see what methods get invoked, what the parameters are. You can let the normal code do it work, and then inspect or event adjust the return value, or any thrown exceptions. And you can do this all in normal Java code. 
 A common example of method-level service advice is to log method entry and exit, complete with parameter values, return values, and thrown exceptions. Other approaches include security checks, transaction management, and other broadly spanning concerns.  
Lets start with a (contrived) example. Lets say you have an existing set of services that have methods that sometimes return null, and you want them to return an empty string instead because you are getting some NullPointerExceptions elsewhere in your application. 
 You could track down the implementation of each service and fix the logic that provides a return value ... or you could advise the methods:  
{noformat} {code} 
  @Match(*) 
public static void adviseNonNull(MethodAdviceReciever adviseNonNull(MethodAdviceReceiver receiver) 
  { MethodAdvice advice = new MethodAdvice() 
...
invocation.proceed();  
if (invocation.getResultType().equals(String.class)  invocation.getResult().equals(null)) 
if (invocation.getResultType().equals(String.class)  invocation.getResult() == null) 
  invocation.overrideResult();   } 
...
 receiver.adviseAllMethods(advice); 
};{noformat} 
{code} 
 This is a method that is placed in a module class. Note the terminology: _advise_ is the verb (to advise a method) and _advice_ is the noun (with this advice). The [MethodAdviceReceiver|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/MethodAdviceReceiver.html] is a wrapper around the service being advised: you can add advice to some or all methods of the service, and also obtain the interface of the service. It is automatically passed into service advisor methods.  
The [guide to injection|#injection.html] [TAPESTRY:IoC - injection] describes what can be injected into a service advisor method. 
 
Service advisor methods {anchor:must}must must have a parameter of type MethodAdviceReciever. MethodAdviceReceiver. 
 
A service will often be advised multiple times; any method may have any number of advice objects applied to it. Some methods may not get any advice. All of this is acceptiable. 
 
Service advisor methods are always void methods (this is different than from [service decorator methods|#decorator.html]). methods|TAPESTRY:IoC - decorator]). 
 
The [...@match|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Match.html] @[Match|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Match.html] annotation indicates that this advice applies to all services (both your own, and those defined by Tapestry). You will want to narrow down which services are actually targetted in most cases. 
 Note that some services, especially those built-in to Tapestry IoC, are marked as [not subject to decoration|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/PreventServiceDecoration.html], this applies to service advice as well as service decoration. 
...
The [MethodAdvice|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/MethodAdvice.html] interface is very simple; it receives an [Invocation|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/Invocation.html] representing a method call. Invocation has methods for inspecting the type and value of the parameters, and for overriding the values of the parameters.  
The call to {{proceed()}} allows the invocation to continue; that is, the original method is invoked. If the method has been advised multiple times, the call to proceed() may chain into the next MethodAdvice object. In any case, after invoking {{proceed()}}, you may inspect and override the result (the return value). 
 Advice is pretty efficient, but it would still be better to apply it only to methods that make sense. We can improve our service advisor method to only advise methods that return String:  
{noformat} {code} 

[CONF] Apache Tapestry BeanEditForm Guide

2010-11-23 Thread confluence







BeanEditForm Guide
Page edited by Christophe Cordenier


Comment:
Fix broken links


 Changes (7)
 



...
One option is to provide an event handler for the prepare or prepareForSubmit events to instantiate an instance to receive the submitted information.  
For a class, Tapestry will select the public constructor with the _most_ parameters. If this is not desirable (for example, if you get an exception), then place the [Inject|../../apidocs/org/apache/tapestry5/ioc/annotations/Inject.html] [Inject|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Inject.html] annotation on the constructor Tapestry should use. 
 h2. Implicit Object Binding 
...
h2. Non-Visual Properties  
In some cases, a property may be updatable and of a supported type for editing, but should not be presented to the user for editing: for example, a property that holds the primary key of a database entity. In such a case, the [NonVisual|../apidocs/org/apache/tapestry5/beaneditor/NonVisual.html] [NonVisual|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beaneditor/NonVisual.html] annotation may be applied to the property (either the getter or the setter method). 
 h2. Default Validation 
...
Default validation for fields is primary determined by property type.  
If desired, additional validation may be specified using the [Validate|../apidocs/org/apache/tapestry5/beaneditor/Validate.html] [Validate|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beaneditor/Validate.html] annotation. 
 h2. Property ordering  
By default, the order in which properties are presented is as defined above (order of the getter method). This can be overridden using the [ReorderProperties|../apidocs/org/apache/tapestry5/beaneditor/ReorderProperties.html] [ReorderProperties|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beaneditor/ReorderProperties.html] class annotation. 
 h2. Default Label 
...
h1. Providing the BeanModel  
The BeanEditForm component operates in terms of a [BeanModel|../apidocs/org/apache/tapestry5/beaneditor/BeanModel.html], [BeanModel|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beaneditor/BeanModel.html], which describes the properties, their presentation order, labels and so forth. 
 Normally, the BeanEditForm automatically creates the BeanModel as needed, based on the type of object bound to its object parameter. 
...
First, decide on a logical name for the data type. For example, you may decide that the BigDecimal type will represent currency in your application, so name the data type currency.  
Next, you must make contributions to the [DataTypeAnalyzer|../apidocs/org/apache/tapestry5/services/DataTypeAnalyzer.html] [DataTypeAnalyzer|http://tapestry.apache.org/current/apidocsapidocs/org/apache/tapestry5/services/DataTypeAnalyzer.html] or [DefaultDataTypeAnalyzer|../apidocs/org/apache/tapestry5/services/DefaultDataTypeAnalyzer.html] [DefaultDataTypeAnalyzer|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/internal/services/DefaultDataTypeAnalyzer.html] services to match properties to your new name. 
 DataTypeAnalyzer is a chain of command that can make match properties to data types based on property type or annotations on the property. In general, DefaultDataTypeAnalyzer is used, as that only needs to consider property type. DefaultDataTypeAnalyzer matches property types to data types, based on a search up the inheritance path. 
...
{code}  
Finally, we tell the BeanEditForm component about the editor via a contribution to the [BeanBlockSource|../apidocs/org/apache/tapestry5/services/BeanBlockSource.html] [BeanBlockSource|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/BeanBlockSource.html] service: 
 {code:java} 
...

Full Content

Using the BeanEditForm Component

Tapestry includes a powerful component capable of generating a complete create/edit user interface for a typical JavaBean, BeanEditForm.

BeanEditForm analyzes the the properties of the bean, locating just those properties that are readable and writable. It filters down to properties whose type is mapped to a known editor (this is described in more detail below).

The default ordering for properties is in the order in which the getter methods for the properties are defined. When a super-class defines edittable properties, those are ordered before sub-class properties.

Supported Types

The default set of property types 

[CONF] Apache Tapestry Hibernate

2010-11-23 Thread confluence







Hibernate
Page edited by Christophe Cordenier


Comment:
Fix broken links


 Changes (3)
 



...
A number of more esoteric ideas in Hibernate are not supported, including nested transactions and supporting multiple persistence units.  
The [tapestry-hibernate-core|../tapestry-hibernate-core/] tapestry-hibernate-core module allows non-Tapestry applications to access Hibernate. 
 h1. Licensing Issues  
Hibernate is licensed under the Lesser GNU Public License. This is more restrictive license than the Apache Software License used by the rest of Tapestry. The restrictions mostly apply to redistricbuting Hibernate, especially in any altered form, and will likely be irrelevant to the vast majority of users, but you should be aware. 
 This library is compiled against version *3.3.1.GA* of Hibernate (and version 3.4.0.GA of hibernate-annotations), but should work with more recent versions. 
...
* Transactions are now _aborted_ (no longer _committed_) at the end of each request: you must now explicitly commit the transaction if changes are to be saved. * The new @CommitAfter annotation for component and service methods can now commit the transaction automatically after the method is invoked. 
* [HibernateGridDataSource|../apidocs/org/apache/tapestry5/hibernate/HibernateGridDataSource.html] [HibernateGridDataSource|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/hibernate/HibernateGridDataSource.html] can be used with the Grid component to support optimized queries against large data sets. 

Full Content

Tapestry/Hibernate Integration Library

This library integrates into Tapestry 5 to provide out-of-the-box support for using Hibernate 3 as the backend for normal CRUD style applications.

For at least the first pass, this will represent access to the native Hibernate interfaces, exposed in a thread-safe manner, within a session-per-request strategy.

A number of more esoteric ideas in Hibernate are not supported, including nested transactions and supporting multiple persistence units.

The tapestry-hibernate-core module allows non-Tapestry applications to access Hibernate.

Licensing Issues

Hibernate is licensed under the Lesser GNU Public License. This is more restrictive license than the Apache Software License used by the rest of Tapestry. The restrictions mostly apply to redistributing Hibernate, especially in any altered form, and will likely be irrelevant to the vast majority of users, but you should be aware.

This library is compiled against version 3.3.1.GA of Hibernate (and version 3.4.0.GA of hibernate-annotations), but should work with more recent versions.

What's New?


	Transactions are now aborted (no longer committed) at the end of each request: you must now explicitly commit the transaction if changes are to be saved.
	The new @CommitAfter annotation for component and service methods can now commit the transaction automatically after the method is invoked.
	HibernateGridDataSource can be used with the Grid component to support optimized queries against large data sets.





Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry IoC - startup

2010-11-23 Thread confluence







IoC - startup
Page edited by Christophe Cordenier


Comment:
Fix broken links


 Changes (1)
 



...
{since:since=5.2}{since}  
Instead of making contributions to the RegistryStartup service configuration you can provide startup methods inside your modules. A startup method is a static or instance method of a module annotated with [Startup|../apidocs/org/apache/tapestry5/ioc/annotations/Startup.html] [Startup|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Startup.html] annotation. Each module is allowed to contain several startup methods. 
 {code:java} 
...

Full Content

Registry Startup

It is possible to provide extra logic to be executed at Registry startup, by making contributions to the RegistryStartup service configuration.

The values contributed are Runnable objects. The configuration is ordered, so it is possible to control in what order the objects are executed.

RegistryStartup occurs after eager loaded services are instantiated.

Here's an example of a module that makes a contribution.



public class MyModule
{
  public static void contributeRegistryStartup(OrderedConfigurationRunnable configuration)
  {
configuration.add("MyContributionName", new Runnable() { ... });
  }
}


Generally, these contributions are in the form of inner classes; if they were services, they could just be eagerly loaded.

Startup Methods



Added in 5.2


Instead of making contributions to the RegistryStartup service configuration you can provide startup methods inside your modules. A startup method is a static or instance method of a module annotated with Startup annotation. Each module is allowed to contain several startup methods.



public class MyModule
{

  @Startup
  public static void initMyApplication(Logger logger, MyService service)
  {
logger.info("Starting up...");

service.init();
  }
}





Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry Spring

2010-11-23 Thread confluence







Spring
Page edited by Christophe Cordenier


Comment:
Fix broken links


 Changes (6)
 



...
h1. Changes From 5.0  
You may now use the @Inject or @InjectService annotations inside Spring beans; these will be resolved to Tapestry services or other objects available via the MasterObjectProvider. Please see the [detailed guide to Injection|../tapestry-ioc/injection.html]. Injection|Injection]. 
 The dependency on Spring is no longer scope provider and has changed to 2.5.6. 
...
h2. Injecting beans  
Inside your component classes, you may use the [Inject|../apidocs/org/apache/tapestry5/ioc/annotations/Inject.html] [Inject|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Inject.html] annotation. Typically, just the field type is sufficient to identify the Spring bean to inject: 
 {code:java} 
...
  private UserDAO userDAO;{code}  
Searching for Spring beans is threaded into the [MasterObjectProvider service|../tapestry-ioc/injection.html]. service|Injection]. The Spring context becomes one more place that Tapestry searches when determining the injection for a injected field or method parameter. 
 {since:since=5.2} 
...
 Inside your Spring beans, you may use 
[Inject|../apidocs/org/apache/tapestry5/ioc/annotations/Inject.html] [Inject|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Inject.html] and 
[Autowired|http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/beans/factory/annotation/Autowired.html] annotations.  
...
h2. Configuring Spring with Tapestry Symbols  
This is accomplished by a BeanFactoryPostProcessors that resolves the values of placeholders from symbol values. In the following example the value of the Beans property productionMode is the value of the Tapestrys  symbol [tapestry.production-mode|..apidocs/org/apache/tapestry5/SymbolConstants.html#PRODUCTION_MODE] [tapestry.production-mode|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/SymbolConstants.html#PRODUCTION_MODE] 
 {code:xml} 
...
h1. ApplicationContextCustomizer  
A new chain-of-command service, [ApplicationContextCustomizer|../apidocs/org/apache/tapestry5/spring/ApplicationContextCustomizer.html] [ApplicationContextCustomizer|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/spring/ApplicationContextCustomizer.html] allows the application context, created by Tapestry, to be customized as it is created. You may contribute your own ApplicationContextCustomizer instances as needed. 
 h1. 5.0 Compatibility Mode 
...

Full Content

Tapestry/Spring Integration

Provides integration between Tapestry and Spring, allowing beans defined by Spring to be injected into Tapestry IoC services, and into Tapestry components.

Changes From 5.0

You may now use the @Inject or @InjectService annotations inside Spring beans; these will be resolved to Tapestry services or other objects available via the MasterObjectProvider. Please see the detailed guide to Injection.

The dependency on Spring is no longer scope "provider" and has changed to 2.5.6.

Spring Beans are no longer exposed as services, unless 5.0 compatibility mode is enabled.

You no longer create a ContextLoaderListener.

These changes represent an unfortunate backwards compatibility issue. If necessary, you can still use tapestry-spring version 5.0.18 with the rest of Tapestry.

Spring Version

This module is compiled and tested against Spring 2.5.6. It should be resonable to override the dependency to earlier versions of Spring, though the code makes use of some APIs that were added to Spring to support JDK 1.5 annotations.

Usage

The integration is designed to be a very thin layer on top of Spring's normal configuration for a web application.

Detailed instructions are available in the Spring documentation. Please omit the part about creating a ContextLoaderListener: this is now done automatically by Tapestry.

web.xml changes

The short form is that you must make two small changes to your application's web.xml.

First, a special filter is used in replace of the standard TapestryFilter:



  filter
filter-nameapp/filter-name
!-- Special filter that adds in a T5 IoC module derived from the Spring WebApplicationContext. --
filter-classorg.apache.tapestry5.spring.TapestrySpringFilter/filter-class
  /filter


Secondly, you may add the normal Spring configuration, consisting of an optional context-param identifying which Spring bean configuration file(s) to load:




[CONF] Apache Tapestry IoC - coerce

2010-11-23 Thread confluence







IoC - coerce
Page edited by Christophe Cordenier


Comment:
Fix broken links


 Changes (2)
 



...
Tapestry frequently must coerce objects from one type to another. By coercion, we mean to convert an object of some type into a new object of a different type with similar content: a common example is coercing a string into an integer or a double.  
Although these types of coercions happens more inside tapestry-core (inlcuding coercions of [component parameters|../tapestry-core/guide/coercion.html]), parameters|IoC - coerce]), this may also happen inside tapestry-ioc, such as when injecting a value, rather than a service, into a builder method. 
 
Like everything else in Tapestry, type coercions are extensible. At the root is the [TypeCoercer|../apidocs/org/apache/tapestry5/ioc/services/TypeCoercer.html] [TypeCoercer|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/services/TypeCoercer.html] service. Its configuration consists of a number of [CoercionTuple|../apidocs/org/apache/tapestry5/ioc/services/CoercionTuple.html]s. [CoercionTuple|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/services/CoercionTuple.html]s. Each tuple defines how to coerce from one type to another. The initial set of coercions is focused primarily on coercions between different numeric types: 
  
...

Full Content

Type Coercion

Tapestry frequently must coerce objects from one type to another. By coercion, we mean to convert an object of some type into a new object of a different type with similar content: a common example is coercing a string into an integer or a double.

Although these types of coercions happens more inside tapestry-core (inlcuding coercions of component parameters), this may also happen inside tapestry-ioc, such as when injecting a value, rather than a service, into a builder method.

Like everything else in Tapestry, type coercions are extensible. At the root is the TypeCoercer service. Its configuration consists of a number of CoercionTuples. Each tuple defines how to coerce from one type to another. The initial set of coercions is focused primarily on coercions between different numeric types:


!images/type-coercer.png!Default Type Coercions There's a few special coercions related to null there; Object -- List wraps a lone object as a singleton list, we then need null -- List to ensure that null stays null (rather than a singleton list whose lone element is a null).

Tapestry can interpolate necessary coercions. For example, say it is necessary to coerce a StringBuffer to an Integer; the TypeCoercer will chain together a series of coercions:


	Object -- String
	String -- Long
	Long -- Integer
Coercing from null



Coercing from null is special; it is not a spanning search as with the other types. Either there is a specific coercion from null to the desired type, or no coercion takes places (and the coerced value is null).

The only built-in null coercion is from null to boolean (which is always false).

Contributing new Coercions

TypeCoercer is extensible, you may add new coercions as desired. For example, let's say you have a Money type that represents an amount of some currency, and you want to be able to convert from BigDecimal to Money. Further, let's assume that Money has a constructor that accepts a BigDecimal as its parameter. We'll use a little Tapestry IOC configuration jujitsu to inform the TypeCoercer about this coercion.



   public static void contributeTypeCoercer(ConfigurationCoercionTuple configuration)
   {
 CoercionBigDecimal, Money coercion = new CoercionBigDecimal, Money()
 {
   public Money coerce(BigDecimal input)
   {
 return new Money(input);
   }
 };
 
 configuration.add(new CoercionTupleBigDecimal, Money(BigDecimal.class, Money.class, coercion)); 
   }


Further, since TypeCoercer knows how to convert Double to BigDecimal, or even Integer (to Long to Double) to BigDecimal, all of those coercions would work as well.

When creating a coercion from null, use Void.class as the source type. For example, the builtin coercion from null to Boolean is implemented as:



  configuration.add(new CoercionTuple(void.class, Boolean.class,
new CoercionVoid, Boolean()
{
public Boolean coerce(Void input)
{
return false;
}
}));





Change Notification Preferences

View Online
|
View Changes









[jira] Created: (TAP5-1354) New T5 site remarks

2010-11-23 Thread Borut Bolcina (JIRA)
New T5 site remarks
---

 Key: TAP5-1354
 URL: https://issues.apache.org/jira/browse/TAP5-1354
 Project: Tapestry 5
  Issue Type: Improvement
  Components: documentation
Reporter: Borut Bolcina


Hello,

first congratulations on a new site!

Today I needed some information about how to test my services, so I visited the 
new site and started browsing. Couldn't find the answer. Can someone give me 
some pointers here?

First I looked in the FAQ and searched for test within the page with my 
browser. Found 2 irrelevant hits, so I went on to the User guide. There is a 
section Test, but covers only testing of pages.

Inspecting further to Tapestry IOC and eye-balling for something useful I 
discovered a link to registry startup, which briefly mentions what would one 
want to use it:

However, you may want to do some integration testing using the Registry from 
within a test case,

I know there are projects out there, so you can inspect the source code to get 
an example of how to test the services, but I feel it should be better 
explained right on the offical page - at least in the FAQ section. It is very 
hard to embrace testing to start with, so some guidance is much appreciated.

And the red background links must go away.

The download section should include maven instruction, at least the dependency 
section of the pom should be listed.

There should be more room at the bottom between the last paragraph and the 
footer. The header on most pages is very white, the bottom has no space at 
all. Give it some air.

Why is there a Book section in the Documentation with only one link to more 
books? It look like an error. At least last two books (their images and 
caption) should be there.

I like the ComponentCheetSheet! A sentance or two more on each annotation would 
be great.

The tutorial Setting up your environment should be improved. Alternatives 
should be described on how to run T5 apps in the Eclipse or other IDEs, but not 
in the text as that would make it too long. I think there should be links for 
alternative setups - like how to run the T5 app from a main class and even 
start VisualVM for early debugging and optimizing (each alternative has pros 
and cons). There is no mention of m2eclipse plugin. Of course one can use JDK 6 
also - only 1.5 is there. There is a sentence: You should not have to download 
this directly. Why are then download links on the download page and no mention 
of maven at the same time. It is confusing for newbs.

The should also be a more visible link to T5 wiki somewhere.

I hope I wasn't too harsh, just wanna put my perspective.

-Borut

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (TAP5-1354) New T5 site remarks

2010-11-23 Thread Howard M. Lewis Ship (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-1354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12935147#action_12935147
 ] 

Howard M. Lewis Ship commented on TAP5-1354:


Thanks for the input; we'll be address most or all of these.  We have a backlog 
of fixups from the move from Maven doc format to Confluence which left a lot of 
things in odd shape.

 New T5 site remarks
 ---

 Key: TAP5-1354
 URL: https://issues.apache.org/jira/browse/TAP5-1354
 Project: Tapestry 5
  Issue Type: Improvement
  Components: documentation
Reporter: Borut Bolcina

 Hello,
 first congratulations on a new site!
 Today I needed some information about how to test my services, so I visited 
 the new site and started browsing. Couldn't find the answer. Can someone give 
 me some pointers here?
 First I looked in the FAQ and searched for test within the page with my 
 browser. Found 2 irrelevant hits, so I went on to the User guide. There is a 
 section Test, but covers only testing of pages.
 Inspecting further to Tapestry IOC and eye-balling for something useful I 
 discovered a link to registry startup, which briefly mentions what would one 
 want to use it:
 However, you may want to do some integration testing using the Registry from 
 within a test case,
 I know there are projects out there, so you can inspect the source code to 
 get an example of how to test the services, but I feel it should be better 
 explained right on the offical page - at least in the FAQ section. It is very 
 hard to embrace testing to start with, so some guidance is much appreciated.
 And the red background links must go away.
 The download section should include maven instruction, at least the 
 dependency section of the pom should be listed.
 There should be more room at the bottom between the last paragraph and the 
 footer. The header on most pages is very white, the bottom has no space at 
 all. Give it some air.
 Why is there a Book section in the Documentation with only one link to more 
 books? It look like an error. At least last two books (their images and 
 caption) should be there.
 I like the ComponentCheetSheet! A sentance or two more on each annotation 
 would be great.
 The tutorial Setting up your environment should be improved. Alternatives 
 should be described on how to run T5 apps in the Eclipse or other IDEs, but 
 not in the text as that would make it too long. I think there should be links 
 for alternative setups - like how to run the T5 app from a main class and 
 even start VisualVM for early debugging and optimizing (each alternative has 
 pros and cons). There is no mention of m2eclipse plugin. Of course one can 
 use JDK 6 also - only 1.5 is there. There is a sentence: You should not have 
 to download this directly. Why are then download links on the download page 
 and no mention of maven at the same time. It is confusing for newbs.
 The should also be a more visible link to T5 wiki somewhere.
 I hope I wasn't too harsh, just wanna put my perspective.
 -Borut

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[CONF] Apache Tapestry Documentation

2010-11-23 Thread confluence







Documentation
Page edited by Bob Harner


Comment:
Updated Books suggestion per suggestion from Borut BolĨina


 Changes (2)
 



...
h2. Books  
[More books|TAPESTRY:Books] ... 
There are at least 8 published [books on Tapestry|TAPESTRY:Books], including two on Tapestry 5 --- and more on the way. 
 h2. Presentations 
...

Full Content



Overview


	Introduction
	Getting Started
	Tutorial
	Frequently Asked Questions
	Component Cheat Sheet  a quick reference to common annotations and method names
	User Guide  a collection of detailed references to the concepts behind Tapestry
	Cookbook  a collection of tips and tricks for commonly occuring patterns in Tapestry
	Deployment Notes  a guide to deploying Tapestry on common application servers
	Developer Information
	Refcard  a six page foldout guide to Tapestry 5.0



Tapestry 5 Reference and API


	Current stable release 5.1.0.5
	
		API (Javadoc)
		Component Reference
		Release Notes
	
	




	Previous stable release 5.0.18
	
		API (Javadoc)
		Component Reference
		Release Notes
	
	




	Current beta release 5.2.4
	
		API (Javadoc)
		Component Reference
		Release Notes
	
	



Articles

If you have any doubts, Tapestry 5 for Nonbelievers will demonstrate why you should choose Tapestry 5

More articles...

Blogs


	Tapestry Central is Howard Lewis Ship's blog. As the creator of Tapestry, he provides a lot of valuable information on Tapestry's latest features and future directions.




	Igor Drobiazko's blog contains a lot of fresh news on Tapestry development and will guide you through the most exciting part of  Tapestry.  Igor is a Tapestry Committer and PMC member.



More blogs ...

Books

There are at least 8 published books on Tapestry, including two on Tapestry 5  and more on the way.

Presentations


	JavaServer Faces 2.0 vs. Tapestry 5: A Head-to-Head Comparison by Igor Drobiazko at Jazoon 2010




	Tapestry 5 : Java power, Scripting ease by Howard Lewis Ship at Devoxx 2009




	More presentations ...



Wiki

Community's Wiki contains a lot of information on different concrete web application use cases.



Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry Logging

2010-11-23 Thread confluence







Logging
Page edited by Howard M. Lewis Ship


 Changes (6)
 



...
Tapestry makes extensive use of [SLF4J|http://www.slf4j.org/] to log details about the creation and operation of your page and component classes.  
The default configuration for logging uses [Log4J|http://logging.apache.org/log4j/] as the logging toolkit, though [this can be changed|../../tapestry-ioc/logging.html]. changed|TAPESTRY:IoC - logging]. 
 h1. Class to Logger 
...
You may mark a field of type [Logger|http://www.slf4j.org/api/org/slf4j/Logger.html] with the @Inject annotation. The proper Logger for your page or component will be injected.  
{noformat} {code} 
public class MyPage { 
...
   . . . 
{noformat} {code} 
 h1. @Log annotation  
You may mark any component method with the [Log|../apidocs/org/apache/tapestry5/annotations/Log.html] @[Log|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Log.html] annotation. Method entry, exit (and any thrown exceptions) will be logged at DEBUG level, along with parameter values and the methods return value. This is very convienient for debugging, especially when placed on event handler methods. 
 h1. Component Transformation Debugging 
...
{noformat}  
h1. Render State Queue Debugging 
 
Occasionally it is useful to get debugging output of all the steps involved in rendering a page. In Tapestry, rendering involves a series of rendering commands passed through a rendering queue (most commands will operate by queuing up additional commands).  A rendering command may represent an element or attribute from a component template, or some template text, or it may represent one render phase when rendering a component. 
 The logger is the pages logger prefixed with tapestry.render.. 
...

Full Content

Logging of Tapestry Components and Pages

Tapestry makes extensive use of SLF4J to log details about the creation and operation of your page and component classes.

The default configuration for logging uses Log4J as the logging toolkit, though this can be changed.

Class to Logger

The logger name for a page or component matches the fully qualified class name. You can configure this in log4j.properties:


log4j.category.org.apache.tapestry5.integration.app1.pages.MerryChristmas=trace



Injecting Loggers

You may mark a field of type Logger with the @Inject annotation. The proper Logger for your page or component will be injected.



public class MyPage
{
  @Inject
  private Logger logger;
  
  . . .



@Log annotation

You may mark any component method with the @Log annotation. Method entry, exit (and any thrown exceptions) will be logged at DEBUG level, along with parameter values and the method's return value. This is very convenient for debugging, especially when placed on event handler methods.

Component Transformation Debugging

Tapestry performs a transformation on your classes as they are loaded, often you want to gain insight into what it has done. Tapestry uses a secondary logger, consisting of the class name with the prefix "tapestry.transformer.", to log (at debug level) the results of transforming the class.

Example:


[DEBUG] MerryChristmas Finished class transformation: InternalClassTransformation[
public org.apache.tapestry5.integration.app1.pages.MerryChristmas extends java.lang.Object
  implements org.apache.tapestry5.runtime.Component, org.apache.tapestry5.runtime.RenderCommand

add default method: public void postRenderCleanup()
default

add default method: public void setupRender(org.apache.tapestry5.MarkupWriter $1, org.apache.tapestry5.runtime.Event $2)
default

add default method: public void beginRender(org.apache.tapestry5.MarkupWriter $1, org.apache.tapestry5.runtime.Event $2)
default

add default method: public void beforeRenderTemplate(org.apache.tapestry5.MarkupWriter $1, org.apache.tapestry5.runtime.Event $2)
default

add default method: public void afterRenderTemplate(org.apache.tapestry5.MarkupWriter $1, org.apache.tapestry5.runtime.Event $2)
default

add default method: public void beforeRenderBody(org.apache.tapestry5.MarkupWriter $1, org.apache.tapestry5.runtime.Event $2)
default

add default method: public void afterRenderBody(org.apache.tapestry5.MarkupWriter $1, org.apache.tapestry5.runtime.Event $2)
default

add default method: public void afterRender(org.apache.tapestry5.MarkupWriter $1, org.apache.tapestry5.runtime.Event $2)
default

add default method: public void cleanupRender(org.apache.tapestry5.MarkupWriter $1, org.apache.tapestry5.runtime.Event $2)
default

add default method: public boolean 

[CONF] Apache Tapestry Hibernate Support FAQ

2010-11-23 Thread confluence







Hibernate Support FAQ
Page edited by Bob Harner


Comment:
Added "How do I use Hibernate in a Tapestry application?" and link to Hibernate page


 Changes (1)
 



h2. Hibernate Support  
h3. How do I use Hibernate in a Tapestry application?  The [Tapestry/Hibernate Integration Library|Hibernate] integrates into Tapestry 5 to provide out-of-the-box support for using Hibernate 3 as the back end for normal CRUD style applications.  
h3. How do I get Hibernate to startup up when the application starts up, rather than lazily with the first request for the application?  
...

Full Content

Hibernate Support

How do I use Hibernate in a Tapestry application?

The Tapestry/Hibernate Integration Library integrates into Tapestry 5 to provide out-of-the-box support for using Hibernate 3 as the back end for normal CRUD style applications.

How do I get Hibernate to startup up when the application starts up, rather than lazily with the first request for the application?

This was a minor problem in 5.0; by 5.1 it is just a matter of overriding the configuration system tapestry.hibernate-early-startup to "true".



Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry Tapestry Inversion of Control Container

2010-11-23 Thread confluence







Tapestry Inversion of Control Container
Page edited by Bob Harner


 Changes (1)
 



h2. Tapestry Inversion of Control Container  
Main article: [Tapestry IoC|IoC]  
h3. Why do I need to define an interface for my services?  Why cant I just use the class itself?  
...

Full Content

Tapestry Inversion of Control Container

Main article: Tapestry IoC

Why do I need to define an interface for my services?  Why can't I just use the class itself?

First of all: you can do exactly this, but you lose some of the functionality that Tapestry's IoC container provides.

The reason for the split is so that Tapestry can provide functionality for your service around the core service implementation.  It does this by creating proxies: Java classes
that implement the service interface.  The methods of the proxy will ultimately invoke the methods of your service implementation.

One of the primary purposes for proxies is to encapsulate the service's lifecycle: most services are singletons that are created just in time.  Just in time means only as soon
as you invoke a method.  What's going on is that the lifecycle proxy (the object that gets injected into pages, components or other service implementations) checks on each method invocation
to see if the actual service exists yet.  If not, it instantiates and configures it (using proper locking to ensure thread safety), then delegates the method invocation to the service.

If you bind a service class (not a service interface and class), then the service is fully instantiated the first time it is injected, rather than at that first method invocation. Further, you
can't use decorations or method advice on such a service.

The final reason for the service interface / implementation split is to nudge you towards always coding to an interface, which has manifest benefits for code structure, robustness, and testability.

My service starts a thread; how do I know when the application is shutting down, to stop that thread?

This same concern applies to any long-lived resource (a thread, a database connection, a JMS queue connection) that a service may
hold onto.  Your code needs to know when the application has been undeployed and shutdown.  This is actually quite easy, by using
a service builder method.  In your module class:



  public MyService buildMyService(ServiceResources resources, RegistryShutdownHub shutdownHub)
  {
final MyServiceImpl service = resources.autobuild(MyServiceImpl.class);

shutdownHub.addRegistryShutdownListener(new RegistryShutdownListener()
{
  public void registryDidShutdown()
  {
service.shutdown();
  }
});

return service;
  }



This code uses the ServiceResources object to build an instance of MyServiceImpl, with all dependencies injected.
It also injects Tapestry's RegistryShutdownHub service and adds a listener. The example assumes that the service implementation
(but not the service interface) includes a shutdown() method.

A valid alternative to this would be to have MyServiceImpl implement RegistryShutdownListener:



  public MyService buildMyService(ServiceResources resources, RegistryShutdownHub shutdownHub)
  {
final MyServiceImpl service = resources.autobuild(MyServiceImpl.class);

shutdownHub.addRegistryShutdownListener(service);

return service;
  }



It is not recommended that MyServiceImpl take RegistryShutdownHub as a constructor parameter and register itself as a listener Doing so is an example of unsafe publishing.



Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry Input Validation

2010-11-23 Thread confluence







Input Validation
Page edited by Bob Harner


Comment:
Fixed ../apidocs/ links.  (More broken links there, though)


 Changes (5)
 



...
h1. Tracking Validation Errors  
Associated with the Form is an [ValidationTracker|../apidocs/org/apache/tapestry5/ValidationTracker.html] [ValidationTracker|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ValidationTracker.html] that tracks all the provided user input and validation errors for every field in the form. The tracker can be provided to the Form via the Forms tracker parameter, but this is rarely necessary. 
 The Form includes methods {{isValid()}} and {{getHasErrors()}}, which are used to see if the Forms validation tracker contains any errors.  
In your own logic, it is possible to record your own errors. Form includes two different versions of method {{recordError()}}, one of which specifies a [Field|../apidocs/org/apache/tapestry5/Field.html] [Field|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/Field.html] (an interface implemented by all form element components), and one of which is for global errors, unassociated with any particular field. 
 h1. Storing Data Between Requests 
...
h1. Centralizing Validation with @Validate  
The [Validate|../apidocs/org/apache/tapestry5/beaneditor/Validate.html] [Validate|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beaneditor/Validate.html] annotation can take the place of the validate parameter of TextField, PasswordField, TextArea and other components. When the validate parameter is not bound, the component will check for the @Validate annotation and use its value as the validation definition. 
 The annotation may be placed on the getter or setter method, or on the field itself. 
...
h1. Overriding the Translator with Events  
The TextField, PasswordField and TextArea components all have a translate parameter, a [FieldTranslator|../apidocs/org/apache/tapestry5/FieldTranslator.html] [FieldTranslator|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/FieldTranslator.html] object that is used to convert values on the server side to strings on the client side. 
 In most cases, the translate parameter is not set explicitly; Tapestry derives an appropriate value based on the type of property being editted by the field. 
...
Again, returning null lets the normal translator do its work.  
The event handler may also throw [ValidationException|../apidocs/org/apache/tapestry5/ValidationException.html] [ValidationException|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ValidationException.html] to indicate a value that cant be parsed. 
 Now, what if you want to perform your own custom validation? Thats another event: validate: 
...

Full Content

Form Input and Validation

The life's blood of any application is form input; this is the most effective way to gather significant information from the user. Whether it's a search form, a login screen or a multi-page registration wizard, forms are how the user really expresses themselves to the application.

Tapestry excels at creating forms and validating input. Input validation is declarative, meaning you simply tell Tapestry what validations to apply to a given field, and it takes care of it on the server and (once implemented) on the client as well.

Finally, Tapestry is able to not only present the errors back to the user, but to decorate the fields and the labels for the fields, marking them as containing errors (primarily, using CSS effects).

Form component

The core of Tapestry's form support is the Form|../tapestry-core/ref/org/apache/tapestry5/corelib/components/Form.html component. The Form component encloses (wraps around) all the other field components such as TextField|../tapestry-core/ref/org/apache/tapestry5/corelib/components/TextField.html, TextArea|../tapestry-core/ref/org/apache/tapestry5/corelib/components/TextArea.html, Checkbox|../tapestry-core/ref/org/apache/tapestry5/corelib/components/Checkbox.html, etc.

The Form component generates a number of component events that you may provide event handler methods for.

When rendering, the Form component emits two notifications: first, "prepareForRender", then "prepare". These allow the Form's container to setup any fields or properties that will be referenced in the form. For example, this is a good chance to create a temporary entity object to be rendered, or to load an entity from a database to be editted.

When user submits the form on the client, a series of steps occur on the server.

First, the Form emits a 

[CONF] Apache Tapestry IoC cookbook - servconf

2010-11-23 Thread confluence







IoC cookbook - servconf
Page edited by Bob Harner


Comment:
Fixed ../apidocs/ links.  (More broken links there, though).  Also fixed the {code} tags


 Changes (18)
 



...
Thus, for certain file extensions, Tapestry guards the resource by attaching an MD5 digest for the resource to the URL. The checksum is derived from the file contents; thus it canapos;t be spoofed from the client unless the client already has the file contents.  
This is controlled by the [ResourceDigestGenerator|../../apidocs/org/apache/tapestry5/services/ResourceDigestGenerator.html] [ResourceDigestGenerator|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/ResourceDigestGenerator.html] service, which uses its configuration to determine which file extensions require an MD5 digest. 
 h2. Contributing to a Service 
...
The Tapestry module makes a contribution into the service configuration:  
{code|borderStyle=solid} 
{code:borderStyle=solid} 
  public static void contributeResourceDigestGenerator(Configurationlt;Stringgt; configuration)   { 
...
  }{code}  
This is a _service contribution method_, a method that is invoked to provide values for a configuration. Weapos;ll see how the service receives these contributions shortly. The [Configuration|../../apidocs/org/apache/tapestry5/ioc/Configuration.html] [Configuration|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/Configuration.html] object is how values are added to the serviceapos;s configuration. Other parameters to a service configuration method are injected much as with a serviceapos;s constructor, or a service builder method. 
 How does Tapestry know which service configuration to update? Itapos;s from the name of the method, anything after the quot;contributequot; prefix is the id of the service to contribute to (the match against service id is case insensitive). 
...
Say your application stored a file on the classpath needed by your application; for illustrative purposes, perhaps it is a PGP private key. You donapos;t want any client to able to download a .pgp file, no matter how unlikely that would be. Thus:  
{code|borderStyle=solid} 
{code:borderStyle=solid} 
public class MyAppModule { 
...
A service receives the configuration as an injected parameter ... not of type Configuration (thatapos;s used for _making_ contributions), but instead is of type Collection:  
{code|borderStyle=solid} 
{code:borderStyle=solid} 
public class ResourceDigestGeneratorImpl implements ResourceDigestGenerator { 
...
Ordered configurations are very similar to unordered configurations ... the difference is that the configuration is provided to the service as a parameter of type List. This is used when the order of operations counts. Often these configurations are related to a design pattern such as [Chain of Command|../command.html] or [Pipeline|../pipeline.html].  
Here, the example is the [Dispatcher|../../apidocs/org/apache/tapestry5/services/Dispatcher.html] [Dispatcher|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/Dispatcher.html] interface; a Dispatcher inside Tapestry is roughly equivalent to a servlet, though a touch more active. It is passed a Request and decides if the URL for the Request is something it can handle; if so it will process the request, send a response, and return true. 
 Alternately, if the Request canapos;t be handled, the Dispatcher returns false.  
{code|borderStyle=solid} 
{code:borderStyle=solid} 
public void contributeMasterDispatcher(OrderedConfigurationlt;Dispatchergt; configuration, . . .) { 
...
}{code}  
With an [OrderedConfiguration|../../apidcos/org/apache/tapestry5/ioc/OrderedConfiguration.html], [OrderedConfiguration|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/OrderedConfiguration.html], each contribution gets a name, which must be unique. Here the names are RootPath, Asset, PageRender and ComponentAction. 
 The add() method takes a name, the contributed object for that name, and then zero or more optional constraints. The constraints control the ordering. The quot;after:quot; constraint ensures that the contribution is ordered after the other named contribution, the quot;before:quot; contribution is the opposite. 
...
The MasterDispatcher service configuration defines a [Chain of Command|../command.apt] and we can provide the implementation using virtually no code:  

[CONF] Apache Tapestry Component Rendering

2010-11-23 Thread confluence







Component Rendering
Page edited by Bob Harner


Comment:
Fixed ../apidocs/ links, and unlinked the H2 headers (not a good practice to link headers)


 Changes (18)
 



...
Whats really mind blowing is that the template and body of a component will often contain ... more components! That means that many different components will be in different phases of their own state machine.  
h2. [SetupRender|../apidocs/org/apache/tapestry5/annotations/SetupRender.html] SetupRender 
 
[...@setuprender|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/SetupRender.html] -- This is where you can perform any one-time per-render setup for your component. This is a good place to read component parameters and use them to set temporary instance variables. 
 
h2. [BeginRender|../apidocs/org/apache/tapestry5/annotations/BeginRender.html] BeginRender 
 
[...@beginrender|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/BeginRender.html] -- For components that render a tag, the start tag is should be rendered here (the close tag should be rendered inside the AfterRender phase). The component can also prevent the template and/or body from being rendered by returning false. 
 Components may or may not have a template. If a component has a template, and the template includes a body element, then the BeforeRenderBody phase will be triggered (giving the component the option of rendering its body or not). 
...
If no methods are annotated with BeginRender, then no special output occurs during this phase, but the template (if present) or body (if no template is present, but the component has a body) will be rendered.  
h2. [BeforeRenderTemplate|../apidocs/org/apache/tapestry5/annotations/BeforeRenderTemplate.html] BeforeRenderTemplate 
 
[...@beforerendertemplate|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/BeforeRenderTemplate.html] -- This phase exists to allow a component to decorate its template (creating markup around the template generated markup), or to allow a component to skip its template. 
 
h2. [BeforeRenderBody|../apidocs/org/apache/tapestry5/annotations/BeforeRenderBody.html] 
h2.BeforeRenderBody 
 
Phase [...@beforerenderbody|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/BeforeRenderBody.html] -- This phase is associated with a components body (the portion of its containers template that the component occupies). The BeforeRenderBody phase allows the component the ability to skip the body, while still rendering the rest of the components template (if any). 
 If no methods are annotated with BeforeRenderBody, then the body will be rendered by default. Again, this occurs when the body element of the components template is reached, or automatically if the component has no template (but the component does have a body).  
h2. [AfterRenderBody|../apidocs/org/apache/tapestry5/annotations/AfterRenderBody.html] AfterRenderBody 
 
Phase that [...@afterrenderbody|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/AfterRenderBody.html] -- This phase is executed after the body is rendered; this only occurs for components with a body. 
 
h2. [AfterRender|../apidocs/org/apache/tapestry5/annotations/AfterRender.html] AfterRender 
 
[...@afterrender|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/AfterRender.html] -- This phase complements BeginRender, and is often used to render the close tag that matches the start tag rendered in the BeginRender phase. In any case, the AfterRender phase can continue on to CleanupRender, or revert back to BeginRender (as in our Count component example, above). 
 If no methods are annotated with AfterRender, then no special output occurs, and the CleanupRender phase is triggered.  
h2. [CleanupRender|../apidocs/org/apache/tapestry5/annotations/CleanupRender.html] CleanupRender 
 
The counterpart to SetupRender, this allows final cleanups to occur. 
[...@cleanuprender|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/CleanupRender.html] -- This is the counterpart to SetupRender, allowing final cleanup to occur. 
 h1. Using Method Names instead of Annotations 
...
h1. Rendering Components  
Instead of returning true or false, a render phase method may return a component. The component may have been injected via the