On 12.09.2012 21:38, Alec Swan wrote:
PackageResourceReference IS-A ResourceReference and neither has a no-arg 
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;

    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.


To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to