Class Trigger

  • public class Trigger
    extends Object
    Triggers an arbitrary event during rendering. This is often useful to add JavaScript to a page or a component (via calls to the JavaScriptSupport environmental).
    Component Parameters 
    NameTypeFlagsDefaultDefault Prefix
    eventString  literal


    In this example, we are showing how to trigger an event from the template of a page. When the following page is rendered the both instances of the component Trigger publish an arbitrary event.


    <html xmlns:t="">
            <h1>Trigger Demo</h1>
            <p> ... </p>
            <t:trigger event="addAdditionalScriptLinks"/>
            <p> ... </p>
            <t:trigger event="provideAdditionalMarkup"/>

    Inside the handler method for the event addAdditionalScriptLinks we add a link to a JavaScript file. The handler method for the event provideAdditionalMarkup provides some additional markup. The MarkupWriter is passed as the event context.

    public class TriggerDemo
        private JavaScriptSupport jsSupport;
        @Inject @Path("context:js/scripts.js")
        private Asset scripts;
        public void onAddAdditionalScriptLinks()
        public void onProvideAdditionalMarkup(MarkupWriter writer)
    • Constructor Detail