As DateInput doesn't have an element of its own, it
doesn't have a dedicated name attribute so the getElementName method will be
very simple:
public String getElementName()
{
return null;
}
The DateInput component does contain three Select components, but Tapestry will
take care of the names of those.
The label can be specified by the component user, but not necessarily, so we need to
provide an optional property for this, and then return the value of this property in
the getLabel method, like this:
@Parameter (defaultPrefix = "literal")
private String label;
public String getLabel()
{
return label;
}
However, if we leave it like this and the component doesn't receive any label when
defined in a page, like in the previous example, nothing will be displayed by the
Label component associated with it. With minimal effort, we can ask Tapestry to
provide a label in case it wasn't specified by the user.
Tapestry will first search for a message with the key componentId-label (where
componentId is the unique ID for our component, the one returned by getClientId
method). If such a message exists in one of the accessible message catalogs (those for
the component, its page or the whole application), it will be displayed by the label.
Pages:
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274