org.chenillekit.tapestry.core.mixins.OnEvent

OnChange mixin catch the browser event "onChange" from a select component and redirect it to your application via tapestry event "change".

[JavaDoc]

Component Inheritance

Component Parameters

Name Type Flags Default Default Prefix Description
context java.util.List NOT Allow Null prop The context for the link (optional parameter). This list of values will be converted into strings and included in the URI. The strings will be coerced back to whatever their values are and made available to event handler methods.
event String Required, NOT Allow Null literal
onCompleteCallback String NOT Allow Null literal the javascript callback function (optional). function has one parameter: the response text
stop boolean NOT Allow Null literal Event.stop

Examples

In this example, we are showing how to use OnEvent.

MyPage.tml

                    
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
    <body>
        <h1>Hello Guys and Dolls</h1>

        <form t:type="Form">
        <input t:type="TextField" value="textFieldValue" t:mixins="ck/OnEvent"
            event="blur" onCompleteCallback="onCompleteFunction"/>;
        </form>

        <p>
        for text field the javascript event returns : <span id="onTextFieldChangeResult"></span>
        </p>

        <script type="text/javascript">
        function onTextFieldCompleteFunction(response)
        {
            $('onTextFieldChangeResult').update("<strong>" + response.translatedValue + "</strong>");
        }
    </body>
</html>

                

MyPage.java

                    
@OnEvent(component = "textfield", value = 'blur')
public JSONObject onBlurEvent(String value)
{
	String translatedValue = "Please welcome me before speek!";

	if (value.equalsIgnoreCase("hello")
		translatedValue = "Hello to you, too!"

    return new JSONObject().put("translatedValue", translatedValue);
}

                

Back to index