This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Component Events

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixed bad links due to copy-paste from cwiki-test

...

Notice that Review.tml contains an ActionLink component in a loop. For each rendering within the loop, the ActionLink component creates a component event request URL, with the event type set to "action". In this case, each URL might look like:

    http://localhost:8080/review.edit/3

This URL identifies the page that contains the component ("review"), the Component id of the component within the page ("edit"), and the context value ("3", the "id" property of the document). Additional context values, if any, are appended to the path. (The URL may also contain the event name, unless, as here, it is "action".)

...

Method Return Values

Main Article: Component Events Page Navigation

For page navigation events (originating in components such as EventLink, ActionLink and Form), the value returned from an event handler method determines how Tapestry will render a response.

  • Null: For no value, or null, the current page (the page containing the component) will render the response.
  • Page: For the name of a page, or a page class or page instance, a render request URL will be constructed and sent to the client as a redirect to that page.
  • URL: For a java.net.URL, a redirect will be sent to the client. (In Tapestry 5.3.x and earlier, this only works for non-Ajax requests.)
  • Zone body: In the case of an Ajax request to update a zone, the component event handler will return the new zone body, typically via an injected component or block.
  • HttpError: For an HttpError, an error response is sent to the client.
  • Link: For a Link, a redirect is sent to the client.
  • Stream: For a StreamResponse, a stream of data is sent to the client
  • boolean: true prevents the event from bubbling up further; false lets it bubble up. See Event Bubbling, below.

See Component Events Page Navigation for more details.

Multiple Method Matches

...

The latter two should be avoided, they may be removed in a future release. In all of these cases, the context EventContext parameter acts as a freebie; it doesn't match against a context value as it represents all context values.

...

A parameter may be annotated with the @RequestParameter annotation; this allows query parameters (?name1=value1&name2=value2, etc) to be extracted from the request, converted to the correct type, and passed to the method. Again, this doesn't count against the event context values.

See the example in the Component Events Link Components FAQ.

Method Matching

An event handler method will only be invoked if the context contains at least as many values as the method has parameters. Methods with too many parameters will be silently skipped.

...

The return value of the exception event handler replaces the return value of original event handler method. For the typical case (an exception thrown by an "activate" or "action" event), this will be a navigational response such as a page instance or page name.

...

Wiki Markup
{float:right|background=#eee|padding=0 1em}
    *JumpStart Demo:*
    [AJAX Components CRUD|http://jumpstart.doublenegative.com.au/jumpstart/together/ajaxcomponentscrud/persons]
{float}
If you want your own component to trigger events, just call the triggerEvent method of ComponentResources from within the your component class.

For example, the following triggers an "updateAll" event. A containing component can then respond to it, if desired, with an "onUpdateAll()" method in its own component class.

...