Hi Paul,
How exactly is a Viewable template resolved and how may I influence
this? It would be handy if one could proxy from a resource higher up the
resource tree, down to a specific case. For instance, in the following I
am trying to setup a simple showcase shortcut (easy to remember) to
another complex sub-resource (hard to remember), by manually
instantiating the resource and calling it with the ServletContext passed
along:
@Path("/")
class RootResource{
@GET
@Path("showcase.html")
@Produces("text/html")
public StreamingOutput getShowCase(){
return new
ChartResource(servletContext).getAsPngStreamingOutput("en",
"0125685:md5...", "...");
}
}
@Path("/{language}/{credentials}/chart/")
class ChartResource{
@GET
@Path("{query}.html")
@Produces("text/html")
public StreamingOutput getAsPngStreamingOutput(
@PathParam("language") String language,
@PathParam("credentials") String credentials,
@PathParam("query") String query)){
return Response.ok( new Viewable("chart", this) ).build();
}
}
The above delegation works for most resources but not for Viewables
(java.io.IOException: The template name, chart, could not be resolved to
a fully qualified template name). I figure this is due to Jersey looking
for the "chart" template in the RootResource folder rather than the
ChartResource folder. Any idea how I may go about accomplishing this
proxy behavior with Viewables (other than placing redundant templates,
and modifying them to reflect changed path)?
Only thing I can think of is using a forward/relocation response, but by
my experiences not all HTTP clients (non-heavyweight browsers) cope well
with this.
/Casper