Documentation
- User's Guide
- JavaDocs
- Tapestry component docs
- Search Trails on Web (Google co-op)
Project information
- Release history
- Roadmap
- License
- Source repository
- Project team
- Dependencies
- Quality
- Dependency convergence
- Code coverage
- Sponsors
|
|||||
|
|||||
Documentation
Project information
|
Overview
Overview Of TrailsIntroductionTrails is a full-stack web application framework.
Trails Stack:Trails allows rapid CRUD application development by automatically creating list and edit pages for POJOs. Trails uses introspection to gather information about bean properties and creates representations and editors depending on their type, for example. Trails itself consists of three main components: a persistence service, a descriptor service that provides meta data for the domain beans and an editor service that provides appropriate editor components based on meta data. For most work, Trails depends on several other frameworks. To understand Trails, it is necessary to understand a bit about the frameworks it uses. Overview of Trails modulesSince Trails 1.1 we've broken the monolithic jar into four different modules. With modularization we've made it possible to separate the presenation and persistence logic and make it easy to introduce new persistence strategies (ie. db4o, jpa) in the future. Additionally, we've separate the test and security related features into their own modules. Trails currently consists of four modules:
SpringSpring is a dependency injection (sometimes known as inversion of control) framework, designed to make configuring and connecting numerous java objects easier. The Spring website explains the benefits and principles of the Spring Framework in great detail, but for a really, really short idea of the Spring advantage, consider the following comparison: Old'n'Busted: singletons, getInstance() methods, lots of static methods, objects that set references to other objects. Why is this bad? Because its difficult to configure or swap objects (this means changing references in multiple places). It's difficult to test, it's difficult to understand the object graph that exists when the application is running. New & Hip: Define objects as POJOs. A Spring configuration configures the objects and sets references from one object to another. When the application starts, Spring instantiates all objects and sets all references. The objects themselves never have to worry about this. Why is this good? Because it's easy to configure; it's easy to swap out objects for different objects (e.g. mock objects for testing); it's easy to test; Spring has lots of fancy extras (AOP for example). How Trails uses SpringThe Spring configuration of a typical Trails application, stored in WEB-INF/applicationContext.xml, defines a number of important objects:
HibernateHibernate is a powerful ORM / persistence framework. It is especially useful in applications that are centered around a java domain model. For complicated databases with lots of stored procedures, Hibernate may not necessarily be the best option. But for Trails it's perfect.
Using Hibernate with Trails is pretty straightforward. For simple applications, you hardly need to do anything other than specifying which database you want to use. For more complex cases, you typically use Hibernate annotations. TapestryTapestry is a powerful web framework; Trails is basically a Tapestry application. Tapestry is component based, like JSF, WebObjects and Wicket, as opposed to being page oriented, like !SpringMVC, Struts, and numerous other web frameworks. Old'n'busted page oriented frameworks: servlets or pages handle (http-)requests, parse parameters and generate a (http-)response. The flow, and programming model, is basically (crudely said): user clicks url, servlet handles url, servlet generates resulting http. New & hip component based: pages are components that contain other components, like links, tables, forms, etcetera. Components consist of a presentation (a HTML fragment, usually) and behaviour. A submit button could have its own onSubmit() method, for example. Components, including their behaviour, can be easily reused across pages. How Trails uses TapestryWithout a component based framework, Trails would be (nearly?) impossible. The editors that Trails' editorService provides are Tapestry components, for example, that contain behaviour specific to the component (i.e. a way to synchronize the editor presentation with POJO property values). The editor components are automatically placed where they are needed, providing flexibility that would be difficult to create with page oriented frameworks. A Trails Tapestry componentTapestry components consist of three parts:
For example, a component's HTML fragment could contain a ForEach component that iterates over a collection provided by a getItemList() method in the java part. OGNLTapestry uses OGNL (Object Graph Navigation Language) to interact with Java objects from within Tapestry HTML code. OGNL is similar to, but more powerful than, JSP's Expression Language (EL). How Trails uses OGNLTapestry components rely heavily on OGNL for component configuration and interaction between HTML and java parts of a component. But Trails itself also uses OGNL, in the editorService for example. The spring configuration for the editorService defines a map, mapping OGNL expressions to editors. For every property on an Edit page, Trails iterates over the editor map, evaluating its keys (OGNL expressions). The first editor is picked whose key evaluates to true. For example, the numberEditor editor is used when the IPropertyDescriptor's =isNumeric() method returns true and the isIdentifier() method returns false: <verbatim> A Trails applicationA Trails application is basically a Tapestry application with a lot of clever stuff. A Home page for a Trails app consists of a list of ListAllLink components; one for every type defined in the descriptorService. By default, this means every hibernate-persisted type. List and Edit pagesA ListAllLink provides a link to a bean's List page. The List page shows a table containing all instances of a particular bean, as well as links to add or search instances. A DefaultList page is used unless you specify a custom list page, which should be called _beanname_List. It is possible to create custom markup for the page, for example, or define the properties that should be shown in the table. By default, ListAllLink displays a bean's identifier as a link. Click the link, and Trails presents an automatically generated DefaultEdit page. This page contains editors for every property, as well as an option to remove the instance. When the DefaultEdit page does not suffice, it is possible to create a custom edit page, _beanname_Edit. Trails editorsTrails provides a number of editors by default (configured in the editorService bean in the Spring configuration), such as:
Possible custom editors could be:
See Adding Custom Editor for a short howto on adding custom editors to Trails.
|
||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
|||||