Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added documentation for @DisableStrictChecks (added in 5.6.2)

Component events are Tapestry's way of conveying a user's interactions with the web page, such as clicking links and submitting forms, to designated methods in your page and component classes. When a component event is triggered, Tapestry calls the event handler method you've provided, if any, in the containing component's class.

Div
stylefloat:right; max-width: 30%; margin: 1em
titleRelated Articles
classaui-label
Content by Label
showLabelsfalse
showSpacefalse
titleRelated Articles
cqllabel = "request-processing" and space = currentSpace()

...

Since
since5.3
Starting in release 5.3, Tapestry will throw an exception if the component identified for the event handler method doesn't exist in the containing component's template. This helps prevent typos. However, this behavior can be overridden using the @DisableStrictChecks annotation (added in release 5.6.2).


In the above example, the editDocument() method will be invoked when any event occurs in in the "edit" component (and has at least one context value).

...

When an event handler method throws an exception (checked or runtime), Tapestry gives the component and its containing page a chance to handle the exception, before continuing on to report the exception. Wiki Markup{float:right|background=#eee|padding=0 1em} *JumpStart Demo:* [Handling A Bad Context|http://jumpstart.doublenegative.com.au/jumpstart/examples/infrastructure/handlingabadcontext/1] {float}

Div
stylefloat: right; max-width: 30%; margin: 1em


Panel
borderColor#eee
titleBGColor#eee
titleJumpStart Demo

Handling A Bad Context



Tapestry triggers a new event, of type "exception", passing the thrown exception as the context. In fact, the exception is wrapped inside a ComponentEventException, from which you may extract the event type and context.

...

If there is no exception event handler, or the exception event handler returns null (or is void), then the exception will be passed to the RequestExceptionHandler service, which (in the default configuration) will render the exception page.

Triggering Events

...

Div
stylemax-width: 30%; float: right; margin: 1em


Panel
borderColor#eee
titleBGColor#eee
titleJumpStart Demo

AJAX Components CRUD



If you want your own component to trigger events, just call the triggerEvent method of ComponentResources from within your component class.

...

The third parameter to triggerEvent is a ComponentEventCallback, which you'll only need to implement if you want to get the return value of the handler method. The return value of triggerEvent() says if the event was handled or not.

 

Scrollbar