Event Links

EventLink renders a link that sends an event name and parameters in the URL when it is clicked.

Here are 3 EventLinks. The first two send event add, and the third one sends event clear. It is explained in the next example.
Count = 11.
Add 1
Add 2
Clear
References: EventLink, Page Navigation, Component Events.

Home


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- We need a doctype to allow us to use special characters like &nbsp; 
     We use a "strict" DTD to make IE follow the alignment rules. -->
     
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd">
<body class="container">
    <h3>Event Links</h3>

    EventLink renders a link that sends an event name and parameters in the URL when it is clicked.<br/><br/>
    
    Here are 3 EventLinks. The first two send event <em>add</em>, and the third one sends event <em>clear</em>. 
    It is explained in the next example.<br/>
        
    <div class="eg"> 
        <div class="alert alert-info">
            Count = ${count}.
        </div>
        
        <t:eventlink t:event="add" t:context="literal:1">Add 1</t:eventlink><br/>
        <t:eventlink t:event="add" t:context="literal:2">Add 2</t:eventlink><br/>  
        <t:eventlink t:event="clear">Clear</t:eventlink>
    </div>

    References: 
    <a href="http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/corelib/components/EventLink.html">EventLink</a>,
    <a href="http://tapestry.apache.org/page-navigation.html">Page Navigation</a>, 
    <a href="http://tapestry.apache.org/component-events.html">Component Events</a>.<br/><br/>
    
    <t:pagelink t:page="Index">Home</t:pagelink><br/><br/>

    <t:tabgroup>
        <t:sourcecodetab src="/web/src/main/java/jumpstart/web/pages/examples/input/EventLinks.tml"/>
        <t:sourcecodetab src="/web/src/main/java/jumpstart/web/pages/examples/input/EventLinks.java"/>
        <t:sourcecodetab src="/web/src/main/resources/META-INF/assets/css/examples/olive.css"/>
    </t:tabgroup>
</body>
</html>


package jumpstart.web.pages.examples.input;

import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.Property;

@Import(stylesheet="css/examples/olive.css")
public class EventLinks {

    // Screen fields
    
    @Property
    private int count;
    
    // The code

    void onActivate(int count) {
        this.count = count;
    }

    int onPassivate() {
        return count;
    }

    void onAdd(int amount) {
        count += amount;
    }
    
    void onClear() {
        count = 0;
    }

}


.eg {
                margin: 20px 0;
                padding: 14px;
                color: olive;
                border: 1px solid #ddd;
                border-radius: 6px;
                -webkit-border-radius: 6px;
                -mox-border-radius: 6px;
}