You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Mike Mander <wi...@gmx.de> on 2011/09/05 14:21:20 UTC

[Migration 1.5] Howto mount my css package resource?

Hi,

i couldn't find a working solution until now for the following usecase.

I would like to include a css file from my package structure in a page.
It sits in <package-path>/res/css.

I included the css in my page:

<code>
     @Override
     public void renderHead(IHeaderResponse response) {
         super.renderHead(response);
         response.renderCSSReference(CssHolder.SCREEN);
     }
</code>

The css holder is a holder for my resourcereferences
<code>
public class CssHolder {
     public static final ResourceReference SCREEN = new 
SharedResourceReference("shop/screen.css");
     public static final ResourceReference PRINT = new 
SharedResourceReference("shop/print.css");
}
</code>

I mounted the resource in application.init():
<code>
         mountResource("shop/screen.css", new 
PackageResourceReference(getClass(), "res/css/screen.css"));
         mountResource("shop/print.css", new 
PackageResourceReference(getClass(), "res/css/print.css"));
</code>

But it is not referenced correctly. In html-output it is

<link  rel="stylesheet"type="text/css"href="wicket/resource/org.apache.wicket.Application/shop/screen.css  <view-source:http://localhost:8080/wicket/resource/org.apache.wicket.Application/shop/screen.css>"/>

In my logs i can find some messages like these, but i don't have a glue what i have to do now.
WARN  - ResourceReferenceRegistry  - Asked to auto-create a ResourceReference, but ResourceReferenceRegistry.createDefaultResourceReference() return null.  [scope: org.apache.wicket.Application; name: shop/screen.css; locale: null; style: null; variation: null]

Can someone please point me the direction?
Thanks
Mike



Re: [Migration 1.5] Howto mount my css package resource?

Posted by Martin Grigorov <mg...@apache.org>.
SharedResourceReference should be used with
application.getSharedResources().add("some/key", new SomeResource());

mountResources(path, ResRef) is something similar, it is new in 1.5
and is more focused into the mount path (/some/nice/url), while
SharedResources is more about the resource and its path is like
/wicket/resources/org.apache.wicket.Application/some/key (aka ugly
path)

On Mon, Sep 5, 2011 at 5:04 PM, Sotil Bertanzetti, Matteo
<ms...@gencat.cat> wrote:
> I don't know, I'm migratin to Wicket 1.5 too.
> I think PackageResourceReference and SharedResourceReference are two
> different approaches, you can use one or other.
>
> Matteo Sotil
>
> -----Mensaje original-----
> De: Mike Mander [mailto:wicket-mike@gmx.de]
> Enviado el: lunes, 05 de septiembre de 2011 15:16
> Para: users@wicket.apache.org
> Asunto: Re: [Migration 1.5] Howto mount my css package resource?
>
> Am 05.09.2011 14:58, schrieb Sotil Bertanzetti, Matteo:
>> Hi,
>>
>> Maybe
>>
>> <code>
>>       @Override
>>       public void renderHead(IHeaderResponse response) {
>>           super.renderHead(response);
>>           response.renderCSSReference(new
>> PackageResourceReference(getClass(), "res/css/screen.css"));
>>       }
>> </code>
>>
>> without mountResource in application.init()
>>
>> Matteo Sotil
>>
>> -----Mensaje original-----
>> De: Mike Mander [mailto:wicket-mike@gmx.de]
>> Enviado el: lunes, 05 de septiembre de 2011 14:21
>> Para: users@wicket.apache.org
>> Asunto: [Migration 1.5] Howto mount my css package resource?
>>
>> Hi,
>>
>> i couldn't find a working solution until now for the following
> usecase.
>>
>> I would like to include a css file from my package structure in a
> page.
>> It sits in<package-path>/res/css.
>>
>> I included the css in my page:
>>
>> <code>
>>       @Override
>>       public void renderHead(IHeaderResponse response) {
>>           super.renderHead(response);
>>           response.renderCSSReference(CssHolder.SCREEN);
>>       }
>> </code>
>>
>> The css holder is a holder for my resourcereferences
>> <code>
>> public class CssHolder {
>>       public static final ResourceReference SCREEN = new
>> SharedResourceReference("shop/screen.css");
>>       public static final ResourceReference PRINT = new
>> SharedResourceReference("shop/print.css");
>> }
>> </code>
>>
>> I mounted the resource in application.init():
>> <code>
>>           mountResource("shop/screen.css", new
>> PackageResourceReference(getClass(), "res/css/screen.css"));
>>           mountResource("shop/print.css", new
>> PackageResourceReference(getClass(), "res/css/print.css"));
>> </code>
>>
>> But it is not referenced correctly. In html-output it is
>>
>> <link
>>
> rel="stylesheet"type="text/css"href="wicket/resource/org.apache.wicket.A
>> pplication/shop/screen.css
>>
> <view-source:http://localhost:8080/wicket/resource/org.apache.wicket.App
>> lication/shop/screen.css>"/>
>>
>> In my logs i can find some messages like these, but i don't have a
> glue
>> what i have to do now.
>> WARN  - ResourceReferenceRegistry  - Asked to auto-create a
>> ResourceReference, but
>> ResourceReferenceRegistry.createDefaultResourceReference() return
> null.
>> [scope: org.apache.wicket.Application; name: shop/screen.css; locale:
>> null; style: null; variation: null]
>>
>> Can someone please point me the direction?
>> Thanks
>> Mike
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> Thanks Matteo,
>
> i did it that way.
>
>         App.init
>         mountResource("shop/screen.css", new
> PackageResourceReference(getClass(), "res/css/screen.css"));
>         Page.renderHead
>         response.renderCSSReference("shop/screen.css", "screen");
>
> But is that still using the resource sharing behavior? Is
> SharedResourceReference useless now?
>
> Thanks
> Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


RE: [Migration 1.5] Howto mount my css package resource?

Posted by "Sotil Bertanzetti, Matteo" <ms...@gencat.cat>.
I don't know, I'm migratin to Wicket 1.5 too. 
I think PackageResourceReference and SharedResourceReference are two
different approaches, you can use one or other.

Matteo Sotil

-----Mensaje original-----
De: Mike Mander [mailto:wicket-mike@gmx.de] 
Enviado el: lunes, 05 de septiembre de 2011 15:16
Para: users@wicket.apache.org
Asunto: Re: [Migration 1.5] Howto mount my css package resource?

Am 05.09.2011 14:58, schrieb Sotil Bertanzetti, Matteo:
> Hi,
>
> Maybe
>
> <code>
>       @Override
>       public void renderHead(IHeaderResponse response) {
>           super.renderHead(response);
>           response.renderCSSReference(new
> PackageResourceReference(getClass(), "res/css/screen.css"));
>       }
> </code>
>
> without mountResource in application.init()
>
> Matteo Sotil
>
> -----Mensaje original-----
> De: Mike Mander [mailto:wicket-mike@gmx.de]
> Enviado el: lunes, 05 de septiembre de 2011 14:21
> Para: users@wicket.apache.org
> Asunto: [Migration 1.5] Howto mount my css package resource?
>
> Hi,
>
> i couldn't find a working solution until now for the following
usecase.
>
> I would like to include a css file from my package structure in a
page.
> It sits in<package-path>/res/css.
>
> I included the css in my page:
>
> <code>
>       @Override
>       public void renderHead(IHeaderResponse response) {
>           super.renderHead(response);
>           response.renderCSSReference(CssHolder.SCREEN);
>       }
> </code>
>
> The css holder is a holder for my resourcereferences
> <code>
> public class CssHolder {
>       public static final ResourceReference SCREEN = new
> SharedResourceReference("shop/screen.css");
>       public static final ResourceReference PRINT = new
> SharedResourceReference("shop/print.css");
> }
> </code>
>
> I mounted the resource in application.init():
> <code>
>           mountResource("shop/screen.css", new
> PackageResourceReference(getClass(), "res/css/screen.css"));
>           mountResource("shop/print.css", new
> PackageResourceReference(getClass(), "res/css/print.css"));
> </code>
>
> But it is not referenced correctly. In html-output it is
>
> <link
>
rel="stylesheet"type="text/css"href="wicket/resource/org.apache.wicket.A
> pplication/shop/screen.css
>
<view-source:http://localhost:8080/wicket/resource/org.apache.wicket.App
> lication/shop/screen.css>"/>
>
> In my logs i can find some messages like these, but i don't have a
glue
> what i have to do now.
> WARN  - ResourceReferenceRegistry  - Asked to auto-create a
> ResourceReference, but
> ResourceReferenceRegistry.createDefaultResourceReference() return
null.
> [scope: org.apache.wicket.Application; name: shop/screen.css; locale:
> null; style: null; variation: null]
>
> Can someone please point me the direction?
> Thanks
> Mike
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Thanks Matteo,

i did it that way.

         App.init
         mountResource("shop/screen.css", new 
PackageResourceReference(getClass(), "res/css/screen.css"));
         Page.renderHead
         response.renderCSSReference("shop/screen.css", "screen");

But is that still using the resource sharing behavior? Is 
SharedResourceReference useless now?

Thanks
Mike

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


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


Re: [Migration 1.5] Howto mount my css package resource?

Posted by Mike Mander <wi...@gmx.de>.
Am 05.09.2011 14:58, schrieb Sotil Bertanzetti, Matteo:
> Hi,
>
> Maybe
>
> <code>
>       @Override
>       public void renderHead(IHeaderResponse response) {
>           super.renderHead(response);
>           response.renderCSSReference(new
> PackageResourceReference(getClass(), "res/css/screen.css"));
>       }
> </code>
>
> without mountResource in application.init()
>
> Matteo Sotil
>
> -----Mensaje original-----
> De: Mike Mander [mailto:wicket-mike@gmx.de]
> Enviado el: lunes, 05 de septiembre de 2011 14:21
> Para: users@wicket.apache.org
> Asunto: [Migration 1.5] Howto mount my css package resource?
>
> Hi,
>
> i couldn't find a working solution until now for the following usecase.
>
> I would like to include a css file from my package structure in a page.
> It sits in<package-path>/res/css.
>
> I included the css in my page:
>
> <code>
>       @Override
>       public void renderHead(IHeaderResponse response) {
>           super.renderHead(response);
>           response.renderCSSReference(CssHolder.SCREEN);
>       }
> </code>
>
> The css holder is a holder for my resourcereferences
> <code>
> public class CssHolder {
>       public static final ResourceReference SCREEN = new
> SharedResourceReference("shop/screen.css");
>       public static final ResourceReference PRINT = new
> SharedResourceReference("shop/print.css");
> }
> </code>
>
> I mounted the resource in application.init():
> <code>
>           mountResource("shop/screen.css", new
> PackageResourceReference(getClass(), "res/css/screen.css"));
>           mountResource("shop/print.css", new
> PackageResourceReference(getClass(), "res/css/print.css"));
> </code>
>
> But it is not referenced correctly. In html-output it is
>
> <link
> rel="stylesheet"type="text/css"href="wicket/resource/org.apache.wicket.A
> pplication/shop/screen.css
> <view-source:http://localhost:8080/wicket/resource/org.apache.wicket.App
> lication/shop/screen.css>"/>
>
> In my logs i can find some messages like these, but i don't have a glue
> what i have to do now.
> WARN  - ResourceReferenceRegistry  - Asked to auto-create a
> ResourceReference, but
> ResourceReferenceRegistry.createDefaultResourceReference() return null.
> [scope: org.apache.wicket.Application; name: shop/screen.css; locale:
> null; style: null; variation: null]
>
> Can someone please point me the direction?
> Thanks
> Mike
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Thanks Matteo,

i did it that way.

         App.init
         mountResource("shop/screen.css", new 
PackageResourceReference(getClass(), "res/css/screen.css"));
         Page.renderHead
         response.renderCSSReference("shop/screen.css", "screen");

But is that still using the resource sharing behavior? Is 
SharedResourceReference useless now?

Thanks
Mike

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


RE: [Migration 1.5] Howto mount my css package resource?

Posted by "Sotil Bertanzetti, Matteo" <ms...@gencat.cat>.
Hi,

Maybe

<code>
     @Override
     public void renderHead(IHeaderResponse response) {
         super.renderHead(response);
         response.renderCSSReference(new
PackageResourceReference(getClass(), "res/css/screen.css"));
     }
</code>

without mountResource in application.init()

Matteo Sotil

-----Mensaje original-----
De: Mike Mander [mailto:wicket-mike@gmx.de] 
Enviado el: lunes, 05 de septiembre de 2011 14:21
Para: users@wicket.apache.org
Asunto: [Migration 1.5] Howto mount my css package resource?

Hi,

i couldn't find a working solution until now for the following usecase.

I would like to include a css file from my package structure in a page.
It sits in <package-path>/res/css.

I included the css in my page:

<code>
     @Override
     public void renderHead(IHeaderResponse response) {
         super.renderHead(response);
         response.renderCSSReference(CssHolder.SCREEN);
     }
</code>

The css holder is a holder for my resourcereferences
<code>
public class CssHolder {
     public static final ResourceReference SCREEN = new 
SharedResourceReference("shop/screen.css");
     public static final ResourceReference PRINT = new 
SharedResourceReference("shop/print.css");
}
</code>

I mounted the resource in application.init():
<code>
         mountResource("shop/screen.css", new 
PackageResourceReference(getClass(), "res/css/screen.css"));
         mountResource("shop/print.css", new 
PackageResourceReference(getClass(), "res/css/print.css"));
</code>

But it is not referenced correctly. In html-output it is

<link
rel="stylesheet"type="text/css"href="wicket/resource/org.apache.wicket.A
pplication/shop/screen.css
<view-source:http://localhost:8080/wicket/resource/org.apache.wicket.App
lication/shop/screen.css>"/>

In my logs i can find some messages like these, but i don't have a glue
what i have to do now.
WARN  - ResourceReferenceRegistry  - Asked to auto-create a
ResourceReference, but
ResourceReferenceRegistry.createDefaultResourceReference() return null.
[scope: org.apache.wicket.Application; name: shop/screen.css; locale:
null; style: null; variation: null]

Can someone please point me the direction?
Thanks
Mike



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