You can put your resources in src/main/webapp but I would not recommend to do 
so (they will work by using an absolute path with the correct web app context) 
but it's quite ugly *imho*

My suggestion is:

Put them somewhere in your package hierarchy below src/main/java where it fits 
best.

Caveat:
When the package is not below in inside the package of the page referring to 
it, e.g. 'com.mycompany.pages.login.LoginPage' refers to 
'com.mycompany.global.css#styles.css' you need to enable parent resources with

IResourceSettings#setParentFolderPlaceholder(...)

(read the javadoc for detailed explanation)

You also you need to wrap your html references with <wicket:link>

e.g.

<wicket:link>
    <link type="text/css" rel="stylesheet" href="../../global/css/styles.css"/>
</wicket:link>

If you miss to enable parent resources the CSS href will get crippled by the 
browser (sic) and not work at all.

Alternatively you can refer to resources from java using e.g.

  IHeaderResponse#renderCSSReference

in the appropriate places of your code. For that to work you usually need an 
'anchor' class that resides in the same package as the resource to refer to it.

cheers
Peter


Am 27.07.2011 um 12:44 schrieb Miroslav F.:

> Use structure:
> .src
> .....java
> ..........com
> ...............myapp
> ...................[HTML & Java go here]
> ...............img
> ...............css
> ...............somethink else you would like
> 
> In img dir put Images.class, in css put Styles.class and so on, for example:
> package com.myapp.images;
> public class Images{
> }
> 
> Then in WebApplication.init() do:
> mountSharedResource("/img/myimage.jpg", new ResourceReference(Images.class,
> "myimage.jpg").getSharedResourceKey());
> 
> and in html file do:
> <img src="./img/myimage.jpg"/>
> 
> No need to do something else in html.
> 
> Hope this helps.
> 
> Miro
> 
> 
> 
> 
>> -----Original Message-----
>> From: eugenebalt [mailto:eugeneb...@yahoo.com] 
>> Sent: Wednesday, 27. July 2011 00:04
>> To: users@wicket.apache.org
>> Subject: Static Files (CSS, JPG) not Found by Wicket in HTML
>> 
>> My project structure looks like this:
>> 
>> .src
>> .....java
>> ..........com
>> ...............myapp
>> ...................[HTML & Java go here]
>> 
>> .web
>> .....img
>> .....css
>> .....WEB-INF
>> 
>> 
>> In my HTML, when I reference "img/image.jpg" or 
>> "css/main.css", these files are not found. I also tried 
>> "/img/image.jpg" and "/css/main.css" and that doesn't work either.
>> 
>> Thanks
>> 
>> 
>> --
>> View this message in context: 
>> http://apache-wicket.1842946.n4.nabble.com/Static-Files-CSS-JP
> G-not-Found-by-Wicket-in-HTML-tp3697146p3697146.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>> 
>> ---------------------------------------------------------------------
>> 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
> 


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

Reply via email to