Prev | Current Page 221 | Next

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"


Another variety of this approach is to use an expansion inside of an attribute value,
as the following fragment demonstrates:





Chapter 7
[ 181 ]
We can also obtain a message in the code of the page class, not only in the template.
To quickly demonstrate this opportunity, we shall do something not very logical.
We shall obtain a text for the "Or register" link from a property of the page class.
This is for demonstration purposes only; normally we would use a ${message:key}
expansion here. However, this approach may become very useful if you format the
message in the code, perhaps inserting some parameters into it (for instance, using
the format method of the MessageFormat class) and then make it available to the
page template. Here is how our example will look in the template:
t:page="Registration">${orRegisterLabel}
And here is the method that returns a text for this link:
@Inject
private Messages messages;
public String getOrRegisterLabel()
{
return messages.get("or-register");
}
Through the Messages object, Tapestry gives our code access to message
catalogs??”both page-specific and root ones.


Pages:
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
pustaki szklane House Extension Kąty Rybackie noclegi kasyno Kołobrzeg