Prev | Current Page 139 | Next

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"

..
public Gender getGender()
{
return gender;
}
public void setGender(Gender gender)
{
this.gender = gender;
}
In case you want to provide a default value, you can do it like this:
private Gender gender = Gender.FEMALE;
We also need to change the template so that each Radio component is associated
with an appropriate value. Previously, to provide such a value, we used the literal
prefix like this:
t:value="literal:M"
This means, for Tapestry, the value that follows the prefix should be understood
literally, in this case, a string. However, the default prefix (the one that is used when
no prefix is defined at all) for the value property of Radio component is prop, which
means that a property of the page class should be used to obtain the value. Let's
change the definition of Radio components like this:
Male
Female
Chapter 4
[ 111 ]
Then provide two read-only properties in the page class:
public Gender getMale()
{
return Gender.MALE;
}
public Gender getFemale()
{
return Gender.FEMALE;
}
If you run the application now, it should continue to work as it did before, with the
difference that gender is now specified as an enumeration, and both the RadioGroup
and Radio components work with it easily.


Pages:
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
wierszyki Kapitalne mieszkania do wynajęcia Warszawa pozycjonowanie katalog stron Ztr alpine