You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Eelco Hillenius <ee...@gmail.com> on 2007/10/16 06:59:53 UTC

Re: Shared Image Resource

> In my application I've added a shared resource. This resource is in a
> seperate resource package (com.test.resources). In that package there's also
> a 'dummy' class ResourceGetter, just to get access to the package. So in the
> init of my application i've putted :
>
> getSharedResources().add("imgStar",
> PackageResource.get(ResourceGetter.class, "star.gif"));
>
> In different pages i need this image multiple times. These pages are in
> different packages. I know I can put the wicket:id on all of my images, but
> I find it a little bit too much trouble to give all those images a different
> id and add them in my java code as well.
> I've tried with the <wicket:link>-tag, but that only works with package
> resources and not with application shared resources (i guess.. correct me if
> i'm wrong). Is there a way i can pass the ResourceGetter-class with the
> wicket:link or img tag, so wicket will look for my resource in
> com.test.resources and not in the package my page is in? And can i also use
> the shared name "imgStar" instead of "star.gif"?
> I want something like :
> <wicket:link>< img src="imgStar" ></wicket:link>

The paths of shared resources are predictable, meaning that you can
hard code them. They follow the form: resources/<class
name>/<resource>, for instance:
src="resources/org.apache.wicket.examples.debug.InspectorBug/bug.png"

You can register class aliases if you want to make this shorter. Also
note that you don't have to explicitly register packaged resources.

Eelco

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