Thanks, Christoph.

I tested your implementation and was able to pull
global/css/styles.css from the browser.

However, the following code threw an exception:
response.renderCSSReference(new
MyPackageResourceReference(MyResources.class, "css/styles.css"),
"screen");

I also tried:
response.renderCSSReference(new
MyPackageResourceReference(MyResources.class,
"global/css/styles.css"), "screen");

In fact request.getUrl().toString() inside of getName() returns an
empty string when called from ResourceReference.getExtension().

Alec

On Wed, Sep 12, 2012 at 1:56 PM, Christoph Leiter
<m...@christophleiter.com> wrote:
> 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: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>

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

Reply via email to