Variable Parameters (1)

To receive a varying number of parameters, use EventContext.

Create a Person...
Review Person 1

No parameters (bad)
Too many parameters (bad)
References: EventContext, Type Coercion, ValueEncoder, PageLink, Page Render Requests, Page Activation, Grammar, Binding Expressions.

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>Variable Parameters (1)</h3>

    <p>To receive a varying number of parameters, use <code>EventContext</code>.</p>
    
    <div class="eg">
        <t:pagelink page="examples/navigation/VariableParameters2" context="'create'">Create a Person...</t:pagelink><br/>
        <t:pagelink page="examples/navigation/VariableParameters2" context="['review',personId]">Review Person ${personId}</t:pagelink><br/><br/>
        
        <t:pagelink page="examples/navigation/VariableParameters2">No parameters (bad)</t:pagelink><br/>
        <t:pagelink page="examples/navigation/VariableParameters2" context="['review',personId,'nonsense']">Too many parameters (bad)</t:pagelink><br/>
    </div>
    
    References: 
    <a href="http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/EventContext.html">EventContext</a>, 
    <a href="http://tapestry.apache.org/typecoercer-service.html">Type Coercion</a>, 
    <a href="http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/ValueEncoder.html">ValueEncoder</a>, 
    <a href="http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/corelib/components/PageLink.html">PageLink</a>, 
    <a href="http://tapestry.apache.org/page-navigation.html#PageNavigation-PageRenderRequests">Page Render Requests</a>, 
    <a href="http://tapestry.apache.org/page-navigation.html#PageNavigation-Pageactivation">Page Activation</a>, 
    <a href="http://tapestry.apache.org/property-expressions.html#PropertyExpressions-Grammar">Grammar</a>, 
    <a href="http://tapestry.apache.org/component-parameters.html#ComponentParameters-BindingExpressions">Binding Expressions</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/navigation/VariableParameters1.tml"/>
        <t:sourcecodetab src="/web/src/main/java/jumpstart/web/pages/examples/navigation/VariableParameters1.java"/>
        <t:sourcecodetab src="/web/src/main/resources/META-INF/assets/css/examples/olive.css"/>
        <t:sourcecodetab src="/web/src/main/java/jumpstart/web/models/Mode.java"/>
    </t:tabgroup>
</body>
</html>


package jumpstart.web.pages.examples.navigation;

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

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

    @Property
    private Long personId;

    void setupRender() {
        personId = new Long(1);
    }

}


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


package jumpstart.web.models;

public enum Mode {
    CREATE, REVIEW, UPDATE, DELETE;
}