You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by eugenebalt <eu...@yahoo.com> on 2012/03/07 19:45:40 UTC

How to Reference a /WebContent File from Wicket

I am adding a shared resource to my app, and I need to reference a file which
resides under /WebContent.

Our app code structure is this:



The /src folder has all the HTML/Java's for Wicket.

The /WebContent has all the images, CSS, and other resources. I need to
reference one of these resources as my shared resource, when initializing
the app.

So I tried this, in Application.init():

File f = new File("test.pdf");                    // test.pdf directly under
WebContent
File f = new File("WebContent/test.pdf");  // test.pdf directly under
WebContent

before adding the bytes of "f" to the shared resource. But the file isn't
found. Thanks

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-Reference-a-WebContent-File-from-Wicket-tp4454190p4454190.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: How to Reference a /WebContent File from Wicket

Posted by eugenebalt <eu...@yahoo.com>.
I got it, it's

Application.class.getResourceAsStream("file.pdf");

(assuming file.pdf is directly under /WebContent).

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-Reference-a-WebContent-File-from-Wicket-tp4454190p4457546.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: How to Reference a /WebContent File from Wicket

Posted by Igor Vaynberg <ig...@gmail.com>.
see how ContextImage does it

-igor

On Wed, Mar 7, 2012 at 10:45 AM, eugenebalt <eu...@yahoo.com> wrote:
> I am adding a shared resource to my app, and I need to reference a file which
> resides under /WebContent.
>
> Our app code structure is this:
>
>
>
> The /src folder has all the HTML/Java's for Wicket.
>
> The /WebContent has all the images, CSS, and other resources. I need to
> reference one of these resources as my shared resource, when initializing
> the app.
>
> So I tried this, in Application.init():
>
> File f = new File("test.pdf");                    // test.pdf directly under
> WebContent
> File f = new File("WebContent/test.pdf");  // test.pdf directly under
> WebContent
>
> before adding the bytes of "f" to the shared resource. But the file isn't
> found. Thanks
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-Reference-a-WebContent-File-from-Wicket-tp4454190p4454190.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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