...
However, you can accomplish the same thing with a little code and markup. For example, to create a link to another page and pass a query parameter, you can replace your PageLink component with a standard <a>
tag:
Code Block |
controls |
true |
linenumberslanguage |
truexml |
|
<a href="" Profile (w/ full details)</a>
|
In the matching Java class, you can create the Link programmatically:
Code Block |
controls |
true |
linenumberslanguage |
truejava |
|
@Inject
private PageRenderLinkSource linkSource;
public Link getProfilePageLink()
{
Link link = linkSource.createPageRenderLinkWithContext(DisplayProfile.class, user);
link.addParameterValue("detail", true);
return link;
}
|
... and in the DisplayProfile page:
Code Block |
controls |
true |
linenumberslanguage |
truejava |
|
public class DisplayProfile
{
void onActivate(@RequestParameter("detail") boolean detail)
{
. . .
}
}
|
...
A similar technique can be used to add query parmeters to component event URLs (the type generated by the ActionLink or EventLink components), by injecting the ComponentResources, and invoking method createEventLink()
.
since |
|
You may also bind a link component's {{parameters}} parameter; this is a Map of additional query parameters to add to the URL. The Map keys should be strings, and the Map values will be encoded to strings. Tapestry 5.3 also adds a literal map syntax to the [property _expression_ language|TAPESTRY:Property Expressions].
|
...
Sometimes it is useful to create a link back to the current page, but you don't always know the name of the page (the link may appear inside a deeply nested subcomponent). Fortunately, this is easy.
Code Block |
|
<t:pagelink page="prop:componentResources.pageName">refresh page</t:pagelink>
|
...