Engine Services and Restart Page

What's an engine service? In Tapestry every time you press a Submit button or click on a link - be it a PageLink, a DirectLink, or whatever - the URL that it generates will select a Tapestry engine service which will do the work. A table of Tapestry's engine services is shown below.

Restart. One such engine service is restart. Its job is to discard your session and take you to the home page (the home page is specified in the .application file).
The ServiceLink component knows how to invoke restart. Here's an example of how to use it in a template:
    <a jwcid="@ServiceLink" service="restart" href="">click here to restart</a>
which produces a link like this:
    click here to restart
which generates a URL like this:
    http://localhost:8080/jumpstart-min/app?service=restart.
You can see the URL by hovering over the link or by right-clicking on this page and choosing to view the page source.

The restart service is so handy during the code-test cycle that it is worth bookmarking the link.

Log out. The recommended way to log a user out of a Tapestry application is to send them through the restart service, eg.
    <a jwcid="@ServiceLink" service="restart" href="">Log Out</a>
But what if there's additional work to do before restarting, such as logging? In that case you would use DirectLink, like this:
    <a jwcid="@DirectLink" listener="listener:doLogout" href="">Log Out</a>
and write a doLogout() method that does the additional work, then gets a link to the restart engine service and redirects to it. To see a working example look at the doLogout() method of Border.java (web/src/java/jumpstart/min/web/components/Border.java)

Do I really need to know? It is not necessary to know the internals of the engine services, but it's good to be aware that they exist.

Write your own service! What's really cute is that if you find something is missing from Tapestry, you can create a new engine service and a component to invoke it, just as the creator of A Hello Service has done.

Components on this page include PageLink, ServiceLink, DirectLink, Submit, ImageSubmit, LinkSubmit, and ExternalLink.

To Login
Engine Service What it Does Example of How To Invoke it Demo Method URL Generated by the Component
page Goes to a page. jwcid="@PageLink" page="pages/examples/simple/HelloWorldPage" Hello World GET /app?service=page &page=pages/examples/simple/HelloWorldPage
restart Discards the session and restarts the app. jwcid="@ServiceLink" service="restart" restart GET /app?service=restart
home Takes you to the application's home page.
jwcid="@ServiceLink" service="home" home GET /app?service=home
reset Discards all cached data if org.apache.tapestry.enable-reset-service=true. See Configuring Tapestry. jwcid="@ServiceLink" service="reset" reset GET /app?service=reset &page=pages/examples/infrastructure/ EngineServicesAndRestartPage
direct Invokes a listener in the current page. The direct service is the workhorse of Tapestry. To the right are 4 different components that use it. jwcid="@DirectLink" listener="listener:doToPage2" To Page 2 GET /app?service=direct &component=$DirectLink &page=pages/examples/infrastructure/ EngineServicesAndRestartPage
jwcid="@Submit" action="listener:doToPage3" POST /app
jwcid="@ImageSubmit" action="listener:doToPage3" POST /app
jwcid="@LinkSubmit" action="listener:doToPage3"
[uses javascript to generate a POST]
To Page 3 POST /app
external Goes to a page that can be referenced externally, ie. a page that implements IExternalPage. jwcid="@ExternalLink" page="..." parameters="ognl:{'Hi', 'There'}" See JumpStart Max for a demo. GET /app?service=external &page=...&sp=SHi&sp=SThere
asset Used behind the scenes to get images and other assets. n/a