SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 154 | Next

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"

Here we shall consider the simplest approach, and in Chapter 8
we'll experiment with a more powerful one.
First of all, we need to create an enumeration to work with the component. It will
be appropriate to name it Country and put into the com.packtpub.celebrities.
model package:
package com.packtpub.celebrities.model;
public enum Country
{
GERMANY, UK, USA
}
I have listed only a few countries here, but you can add as many as you wish. Next,
let's configure the page class to work with the new component:
@Inject
private Messages messages;
public SelectModel getCountries()
{
return new EnumSelectModel(Country.class, messages);
}
@Persist
private Country country;
public Country getCountry()
{
return country;
}
public void setCountry(Country country)
{
this.country = country;
}
Simple Components
[ 122 ]
Interestingly, we are creating an instance of EnumSelectModel, one of
implementations of the SelectModel interface that comes with Tapestry. The
constructor of EnumSelectModel takes two parameters??”the class of an enumeration
that should be used as the source of options and some mysterious Messages object
which we have injected into the page class. What is this Messages object?
Here we are coming very closely to the topic of internationalization and localization
that will be thoroughly discussed in Chapter 7.


Pages:
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6