It’s not that I want the images to be served from a .jar; I just want them to exist in a different place from the code that is creating the Image component.

 

Suppose I have a hundred images I want to be able to pass as a parameter to a page or panel – I have to do all this a hundred times?

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Igor Vaynberg
Sent: Tuesday, March 14, 2006 10:13 AM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] Location of image files

 

there are two parts to this if you want the image to be served from a jar.

one. you have to create an initializer and bind the image as a package resource:
public void init(Application application)
{
        PackageResource.bind(application, Tree.class, "blank.gif");
        ...
}

the Tree.class acts as a scope - the image is assumed to be in the same package as the scope class.

the initializer is needed for clustering reasons. look at wicket.properties and Initializer code in wicket package.

two. you must create a resource reference to your image:
    /** Blank image. */
    public static final ResourceReference BLANK = new PackageResourceReference( Tree.class, "blank.gif");

after this you can create a url for the image in the package like so RequestCycle.get().urlFor(BLANK);

hope this helps,
-Igor


On 3/14/06, Frank Silbermann <[EMAIL PROTECTED]> wrote:

I am writing code that will be shared between two web applications.  The
common code will be packaged in a .jar to be included by both web
applications.

One common component has a requirement to display an image whose
filename (or some other handle) it takes as a parameter.  The images
that will be passed to this component to display are different for the
two web applications.  Therefore, my image files must reside separately
from the code which constructs the wicket.markup.html.image.Image
component.

The constructor for wicket.markup.html.image.Image can take a string
representing the image's file name.  In all of the examples, the image
file exists in the same directory as the component that creates the
Image component.  If the image exists in some other arbitrary location,
what are the rules for absolute or relative path addressing of the image
filename?



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmdlnk&kid0944&bid$1720&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

 

Reply via email to