Postfield Component Index Select

wml:PropertySelection
org.apache.tapestry.wml.PropertySelection
Image Component
 
Description
Creates an WML select to choose a single property from a list of options.
See Also
wml:Go, wml:SelectionField
Parameters
Name Type Direction Required Default Description
name String in yes   The property to set. During rendering, this property is read, and sets the default value of the selection (if it is null, no element is selected). When the <go> is submitted, this property is updated, with the help of SelectionField component, based on the new selection.
model IPropertySelectionModel auto no   The model provides a list of possible labels, and matches those labels against possible values that can be assigned back to the property.

Body: removed
Informal parameters: allowed
Reserved parameters: none

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();
}

Postfield Component Index Select