You are on page 1of 23

Tapestry for Struts

Developers
by Joseph Nusairat

1
Overview of Presentation
 Overview of Struts
 What is Tapestry?
 Tapestry
 Hivemind
 Page
 Components
 HTML
 Validation

2
Overview of Struts
 Struts standard MVC.
 Push path for web development.
 All actions get pushed to something else.
 Path of a request:
 ActionServlet  RequestProcessor  Action
 Final result is a jsp with information pushed
to it.

3
Cons of Struts
 JSPs are unreadable by html developers.
 Action classes are often aware of their front
end environment.
 Action classes are also aware of the
services they are accessing.
 Operation centric like most MVC
frameworks.

4
Overview of Tapestry
 Born around 2000
 Component Centric
 Everything in Tapestry is a component
 Created by Howard Lewis Ship
 Also creator of Hivemind
 Official Release 3.x
 Current Build 4.0

5
What is Tapestry
 Tapestry Mantra
 "objects, methods and properties"
 Listeners
 Tapestry uses listeners not Servlets to drive everything.
 Engines
 Are the builders to encode the objects.
 Object Graph Navigation Language
 Tightly integrated into tapestry.

6
Getting Started
 Jar files you will need:
 Tapestry:
 tapestry-4.0.jar
 tapestry-annotations-4.0.jar
 tapestry-contrib-4.0.jar
 tapestry-portlet-4.0.jar
 Hivemind
 hivemind-1.1.jar
 hivemind-jmx-1.1.jar
 hivemind-lib-1.1.jar
 Common components:
 commons-codec-1.3.jar
 javassist-3.0.jar
 ognl-2.6.7.jar
 oro-2.0.8.jar

7
Getting Started
 Files you need
 tap-demo.application
 Necessary for the tapestry application.
 web.xml
 Updated for the web.
 hivemind.xml
 Needed for the hivemind configurations.

8
Path of Tapestry

9
Hivemind
 The servicing mechanism for Tapestry.
 Before Tapestry 4.0, servicing was built into
tapestry. Now it uses Hivemind services.
 One of the major upgrades for 4.0
 What it brings.
 Prettier URL’s.
 Allows modularization of components.
 Integration into the Java Portlet API.

10
Hivemind
 What do you want to put into hivemind.
 Your state objects.
 Objects that need to be persisted from page to
page.
 Custom validation
 Defines your custom validators.
 Services
 Any interfacing to the middle tier.
 Basically anything you will want access to.

11
Html File
 Regular HTML
 Any regular HTML can be used.
 Components
 Uses JWCID to define components.
 Can use pre-defined or custom components.
 Border
 Enabled to use bordering components.

12
Page
 IPage
 What all pages implement.
 There are a few base ones that you can make use of.
 Is a component
 Make all of yours abstract
 Is equivalent to the Action in usage.
 Listeners
 Defined on the page to be accessed.

13
Listeners
 Pre-Defined
 IExternalPage
 Used when activating from an external page.
 PageBeginRenderListener
 Used upon initial page loading.
 PageEndRenderListener
 Used upon page post loading.
 And Many others …

14
Custom Page Listeners
 Customized Listeners
 Call them from links or submit pages on the app.
 Various ways to set them up.
 Parts of a Listener
 Return
 Can be null or String or Page.
 Name
 Anything one wants
 Parameters
 IRequestCycle cycle
 List of parameters.

15
Page Config File
 Page Specification
 Can define the name of the page class, defaults to this
class.
 Injection
 This allows you to inject services for use that are defined by
hivemind.
 Can also inject state data that can be saved in the session.
 Components
 You can define components for the page.
 These are used for rendering the html pages.

16
Validation
 Validator used with TextField
 Several built in validators.
 Automatic update on FieldLabels
 Can also be customized
 Define in the page or hivemind module.
 Must implement IValidator

17
Component
 IComponent
 All implement this.
 Mainly used to display items on a page.
 Think of them as tag libraries.
 Remember everything you do is a
component.

18
Tacos
 AJAX Framework for Tapestry
 Designed outside of Tapestry, but actively being
developed.
 Jar Files Required
 tacos4-beta-1-lib.jar
 commons-lang-2.1.jar

19
Tacos
 AjaxDirectLink
 Used to recreate link
 Parameters
 Listener
 Parameters
 updateComponents
 effects

20
Tacos
 AjaxForm
 Basically same as AjaxDirectLink

21
Future
 Future Development
 Make classes subclass POJOS

22
Books on the Subject
 Tapestry In Action
 By Howard M. Lewis Ship
 Enjoy Web Development with Tapestry
 By Kent Tong
 Beginning POJOs: From Novice to
Professional
 By Brian Sam-Bodden

23

You might also like