"Restart" and Other Engine Services Page

Restart. Tapestry provides a service called restart, which discards the session and takes you to the application's Home page. Its URL will be something like http://localhost:8080/jumpstart-min/app?service=restart. The ServiceLink component knows how to generate the right URL. When you use it like this:
<a jwcid="@ServiceLink" service="restart" href="">click here to restart</a>
the resulting link is like this: click here to restart.

This service is so handy during the code-test-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 you need the application to do additional work, such as logging, before restarting? Then instead of ServiceLink you'll have to 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)

What's a service? Well, in Tapestry every time you press a Submit button or click on a link, be it a PageLink, a DirectLink, or whatever, you are actually sending a request to a Tapestry engine service which will do the work. There is a table of examples below.

Do I really need to know? It is not essential to know this stuff to develop with Tapestry, but it just might help you debug a problem one day.

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

Example Service What it does Method Generated URL
ServiceLink service="restart" restart Trashes the session and restart the app. GET /app?service=restart
ServiceLink service="home" home Takes you Home, as specified in .application.
GET /app?service=home
ServiceLink service="reset" reset Trashes the page cache. Requires org.apache.tapestry.enable-reset-service=true. See Configuring Tapestry. GET /app?service=reset
&page=pages/starters/RestartAndOtherEngineServicesPage
DirectLink listener="..." direct This service invokes a listener in the current page. It is the workhorse service of Tapestry. GET /app?service=direct&component=$DirectLink
&page=pages/starters/RestartAndOtherEngineServicesPage
POST /app
POST /app
LinkSubmit action="..." POST (uses javascript to put the data into a POST)
/app
ExternalLink page="..." parameters="..." external Goes to a page that can be referenced externally. See JumpStart Max for an example. GET /app?service=external&page=...&sp=...&sp=...
PageLink page="..." page Goes to a page. GET /app?service=page&page=...
ActionLink action [ActionLink is deprecated] GET  
asset Used behind the scenes to get images and other assets.    
To Login