On 12.09.2012 21:38, Alec Swan wrote:
PackageResourceReference IS-A ResourceReference and neither has a no-arg
constructor.
My point exactly. That's why I can't just do mountResource("/global",
new MyRR()) as Martin suggested.
My quick try:
public class MyPackageResourceReference extends PackageResourceReference {
private final String prefix;
public MyPackageResourceReference(Class<?> scope, String prefix) {
super(scope, "dummy");
this.prefix = prefix;
}
@Override
public String getName() {
Request request = RequestCycle.get().getRequest();
String url = request.getUrl().toString();
if (!url.startsWith(prefix)) {
throw new IllegalStateException();
}
return url.substring(prefix.length());
}
}
Use it like:
mountResource("/global", new
MyPackageResourceReference(MyResources.class, "global/"));
It needs to know where it is mounted so it can remove the prefix. Maybe
there's a more elegant way around this but it works.
Christoph
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]