Multiple Method Matches

It's possible for multiple event handler methods to match a single event, but it's rarely a facility that you would use.
The rules are described in the Multiple Method Matches and Event Context sections of Component Events.

Here are some examples:
Link 1
Link 2
The event handlers invoked were...
References: Multiple Method Matches, Event Context, If, Persistent Page Data.

Home

MultipleMethodMatches.tml


<!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_3.xsd">
<head>
    <link rel="stylesheet" type="text/css" href="${context:css/examples/examples.css}"/>
</head>
<body>
    <h1>Multiple Method Matches</h1>
    
    It's possible for multiple event handler methods to match a single event, but it's rarely a facility that you would use. <br/>
    The rules are described in the 
    <em>Multiple Method Matches</em> and <em>Event Context</em> sections of 
    <a href="http://tapestry.apache.org/component-events.html">Component Events</a>.<br/><br/>
    
    Here are some examples:
    
    <div class="eg">
        <a t:type="eventlink" t:event="doSomething" t:id="link1" href="#">Link 1</a><br/>
        <a t:type="eventlink" t:event="doSomething" t:id="link2" t:context="literal:Hello" href="#">Link 2</a><br/>
        
        <t:if t:test="message">
            <span style="color:red;">${message}</span>
        </t:if>
    </div>
    
    References: 
    <a href="http://tapestry.apache.org/component-events.html#ComponentEvents-MultipleMethodMatches">Multiple Method Matches</a>, 
    <a href="http://tapestry.apache.org/component-events.html#ComponentEvents-EventContext">Event Context</a>, 
    <a href="http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/corelib/components/If.html">If</a>, 
    <a href="http://tapestry.apache.org/persistent-page-data.html">Persistent Page Data</a>.<br/><br/>
    
    <a t:type="pagelink" t:page="Index" href="#">Home</a><br/><br/>

    <t:sourcecodedisplay src="/web/src/main/java/jumpstart/web/pages/examples/navigation/MultipleMethodMatches.tml"/>
    <t:sourcecodedisplay src="/web/src/main/java/jumpstart/web/pages/examples/navigation/MultipleMethodMatches.java"/>
    <t:sourcecodedisplay src="/web/src/main/java/jumpstart/web/css/examples/examples.css"/>
</body>
</html>

MultipleMethodMatches.java


package jumpstart.web.pages.examples.navigation;

import org.apache.tapestry5.PersistenceConstants;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;

public class MultipleMethodMatches {

    // Screen fields

    @Property
    @Persist(PersistenceConstants.FLASH)
    private String message;

    // The code

    void onActivate() {
        if (message == null) {
            message = "The event handlers invoked were...";
        }
    }

    void onDoSomething() {
        message += " onDoSomething()";
    }

    Object onDoSomething(String parameter) {
        message += " onDoSomething(parameter)";
        // To prevent onDoSomething() also being called, we'd return true or any other valid non-null value.
        return null;
    }

}

examples.css


body            { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; font-weight: normal; color: #333; line-height: 17px; }
h1              { font-size: 26px; line-height: 20px; } /* For IE 7 */
form            { margin: 0; }                  

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

a               { text-decoration: none; color: #3D69B6; }
a:hover         { text-decoration: underline; }

/* For BeanDisplay */
.eg dl          { margin: 0; color: #333; }
.eg dl.t-beandisplay dd.id  { display: inline; margin-left: 0px; }  /* IE 7 hack */