Thank you for your suggestion Antonio, but I've already tried that approach,
and cannot find a way to access the Definition object from the execute()
method of a ViewPreparer.
Perhaps the Definition could be made part of the ViewPreparer interface in
future?
Regarding which definition, I think that absolutely there is a single
specific definition at the point when rendering occurs. In fact, this is
just about the only time you could claim to know what the definition will
be, as there is can be many definitions using a jsp, and many definitions
that can use a ViewPreparer, and many definitions that extend another given
definition; at runtime all of these resolve such that from a given jsp
PageContext, it makes sense to refer to "the" definition.
My current solution is this:
In BasicTilesConfigurer.java (line 564-620 in v2.0.6):
private void render(TilesRequestContext request, String definitionName)
throws TilesException {
...
Definition definition = getDefinition(definitionName, request);
...
* request.getRequestScope().put( "definition", definition );*
AttributeContext originalContext = getAttributeContext(request);
BasicAttributeContext subContext = new
BasicAttributeContext(originalContext);
subContext.addMissing(definition.getAttributes());
pushContext(subContext, request);
try {
if (definition.getPreparer() != null) {
prepare(request, definition.getPreparer(), true);
}
String dispatchPath = definition.getTemplate();
...
request.dispatch(dispatchPath);
// tiles exception so that it doesn't need to be rethrown.
...
} finally {
popContext(request);
}
}
2008/7/15 Antonio Petrelli <[EMAIL PROTECTED]>:
> 2008/7/15 Stewart Cambridge <[EMAIL PROTECTED]>:
> > <c:out value="${definition.name}"/> <!-- renders "my.tile" -->
>
> The name of a definition? The big problem is that there isn't a single
> definition, when a definition is rendered. A definition could be
> composed of several definitions, so what is *the* definition?
> IMO you can solve your problem by adding a preparer, that puts the
> definition name in request context (but for this please ask the Tiles
> Users mailing list).
>
> Antonio
>