supported-locales")
String locales)
{
supportedLocales = locales;
}
Creating Custom Components
[ 230 ]
public String getSupportedLocales()
{
return supportedLocales;
}
}
One unusual detail here is the tricky looking parameter accepted by the constructor.
Let's look at this parameter closely:
@Inject
@Symbol("tapestry.supported-locales")
String locales
Here, we are using the Tapestry Inversion of Control system and asking it to provide
a parameter (inject into it some String value) to its constructor, when an instance of
the SupportedLocalesImpl class is created. That value can be obtained by following
a symbol (a kind of reference) like tapestry.supported-locales??”and we have
provided the value, en,de ourselves, by configuring the application earlier. Finally,
the service simply returns whatever was provided by the Tapestry IoC.
The next step is to tell Tapestry about the new service by binding together its
interface and implementation. Please have a look at the AppModule class again. You
will find a method named bind which is initially empty, except for the comment that
explains how to use this method. We are going to add just one line of code to it, so
that the method looks like this (the original comment was removed to save space):
public static void bind(ServiceBinder binder)
{
binder.
Pages:
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288