Example
Template
<card id="card1" title="Animal QUIZ" newcontext="true"> <p>Welcome! <br/> Your name: <input jwcid="userInput" name="username" title="Your name" value=""/> </p> <p> Difficulty: <b jwcid="selectLevel"/> </p> <p> <do type="help" label="Instructions"> <go href="#help"/> </do> <do type="options" label="Zoo home"> <go jwcid="@ServiceLink" service="ognl:@org.apache.tapestry.Tapestry@HOME_SERVICE" renderer="ognl:@org.apache.tapestry.wml.GoLinkRenderer@SHARED_INSTANCE" href=""/> </do> </p> <p> <anchor title="Start">Start <go jwcid="go"> <postfield jwcid="username" name="username" value="username"/> <postfield jwcid="level" name="level" value="level"/> </go> </anchor> <br/> <anchor title="Instructions">Instructions <go href="#help"/> </anchor> </p> </card>
Specification
<page-specification class="org.apache.tapestry.wap.quiz.Home">
<component id="username" type="wml:Postfield">
<binding name="value" expression="username"/>
<binding name="name" expression="components.userInput.name"/>
</component>
<component id="level" type="wml:SelectionField">
<binding name="value" expression="level"/>
<binding name="model" expression="components.selectLevel.model"/>
<binding name="name" expression="components.selectLevel.name"/>
</component>
<component id="userInput" type="wml:Input">
<static-binding name="name">username</static-binding>
<binding name="value" expression="username"/>
</component>
<component id="selectLevel" type="wml:PropertySelection">
<static-binding name="name">level</static-binding>
<binding name="model" expression="@org.apache.tapestry.wap.quiz.Home@LEVEL_MODEL"/>
</component>
<component id="go" type="wml:Go">
<binding name="stateful" expression="false"/>
<binding name="listener" expression="listeners.start"/>
</component>
<property-specification name="username" type="java.lang.String" persistent="yes"/>
<property-specification name="level" type="java.lang.String" persistent="yes" initial-value='"easy"'/>
</page-specification>
Java
public abstract class Home extends Deck
{
public static final IPropertySelectionModel LEVEL_MODEL = new StringPropertySelectionModel
(new String[] { Global.EASY_LEVEL, Global.MEDIUM_LEVEL, Global.HARD_LEVEL });
public void start(IRequestCycle cycle)
{
.....
.....
}
public abstract String getUsername();
public abstract String getLevel();
}
|