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


<!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>Multiple Method Matches</h3>
    
    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">
        <t:eventlink event="doSomething" t:id="link1">Link 1</t:eventlink><br/>
        <t:eventlink event="doSomething" t:id="link2" context="literal:Hello">Link 2</t:eventlink><br/>
        
        <t:if t:test="message">
            <br/>
            <div class="alert alert-info">
                ${message}
            </div>
        </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.4/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/>
    
    <t:pagelink page="Index">Home</t:pagelink><br/><br/>

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


package jumpstart.web.pages.examples.navigation;

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

@Import(stylesheet="css/examples/plain.css")
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;
    }

}


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