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 2011/07/27 00:03:35 UTC

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-JPG-not-Found-by-Wicket-in-HTML-tp3697146p3697146.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: Static Files (CSS, JPG) not Found by Wicket in HTML

Posted by eugenebalt <eu...@yahoo.com>.
>From googling this issue, it looks like in a Wicket project, "webapp" is
under "src"...

In my project, src and web are on the same level. Is this problem? This
project was created by NetBeans and I'd prefer not to modify it, with all
the web.xml dependencies etc.

Looking at the rendered result, I see that the references got rendered with
a ".." before them:

img src="../img/banner.JPG"
href="../css/main.css"

Is there any way to prevent that initial ".." rendering?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Static-Files-CSS-JPG-not-Found-by-Wicket-in-HTML-tp3697146p3697254.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: Static Files (CSS, JPG) not Found by Wicket in HTML

Posted by Peter Ertl <pe...@gmx.org>.
put the images in an package and use wicket:link properly ... no need to mount at all

Am 27.07.2011 um 14:45 schrieb Dmitriy Ivanov:

> Miroslav, is there way to achive some kind of "whole package mounting"
> without explicit mounting of each image?
> 
> 2011/7/27 Miroslav F. <mi...@seznam.cz>
> 
>> 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:eugenebalt@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-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
>> 
>> 
> 
> 
> -- 
> WBR, Джонсон.


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


Re: Static Files (CSS, JPG) not Found by Wicket in HTML

Posted by Peter Ertl <pe...@gmx.org>.
I was assuming you use maven

'src/main/java'

and 

'src/main/webapp'

see http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

If you don't use maven you have to choose the corresponding directory in your build / IDE environment...

Am 27.07.2011 um 15:08 schrieb eugenebalt:

> Guys, I tried creating new folders under src/, naming them main/ and then
> webapp/ under main/, with img and css subdirectories, but that didn't work
> either, I don't know why. It was supposed to find it automatically.
> 
> But anyway, I don't want to reorganize my project structure. It's an
> existing NetBeans project and I have dependencies in it, e.g. web.xml.
> 
> So my question, how can I get Wicket to display my static resources
> referenced in HTML based on my *existing* structure, which I described in
> the first post? What is the Java code for that?
> 
> I need to be able to reference img src="[img]" for example.
> 
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Static-Files-CSS-JPG-not-Found-by-Wicket-in-HTML-tp3697146p3698424.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


Re: Static Files (CSS, JPG) not Found by Wicket in HTML

Posted by eugenebalt <eu...@yahoo.com>.
Guys, I tried creating new folders under src/, naming them main/ and then
webapp/ under main/, with img and css subdirectories, but that didn't work
either, I don't know why. It was supposed to find it automatically.

But anyway, I don't want to reorganize my project structure. It's an
existing NetBeans project and I have dependencies in it, e.g. web.xml.

So my question, how can I get Wicket to display my static resources
referenced in HTML based on my *existing* structure, which I described in
the first post? What is the Java code for that?

I need to be able to reference img src="[img]" for example.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Static-Files-CSS-JPG-not-Found-by-Wicket-in-HTML-tp3697146p3698424.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: Static Files (CSS, JPG) not Found by Wicket in HTML

Posted by Dmitriy Ivanov <jo...@gmail.com>.
 Miroslav, is there way to achive some kind of "whole package mounting"
without explicit mounting of each image?

2011/7/27 Miroslav F. <mi...@seznam.cz>

> 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:eugenebalt@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-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
>
>


-- 
WBR, Джонсон.

Re: Static Files (CSS, JPG) not Found by Wicket in HTML

Posted by eugenebalt <eu...@yahoo.com>.
Can I do, in my Application class,

getResourceSettings().addResourceFolder(this.getServletContext().getContextPath())

? The theory being, that all folders (src and web) will be added as resource
folders, and my img and css files will be found.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Static-Files-CSS-JPG-not-Found-by-Wicket-in-HTML-tp3697146p3698590.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: Static Files (CSS, JPG) not Found by Wicket in HTML

Posted by Martin Grigorov <mg...@apache.org>.
Trust me! ;-)

See the javadoc of
org.apache.wicket.markup.parser.filter.RelativePathPrefixHandler

On Wed, Jul 27, 2011 at 4:52 PM, Peter Ertl <pe...@gmx.org> wrote:
>> Actually you just have to use "css/styles.css" and Wicket will
>> "relativize" it for you.
>> There is a special IMarkupFilter for that.
>
> but only if wrap it inside <wicket:link>
>
> this will not work for resources in src/main/webapp but only for package resources
>
> without <wicket:link> the markup will just be rendered as-is and wicket will not even touch it. this is the standard behavior for static html with hrefs.
>
> Am 27.07.2011 um 15:40 schrieb Martin Grigorov:
>
>> On Wed, Jul 27, 2011 at 3:54 PM, Peter Ertl <pe...@gmx.org> wrote:
>>> if your login page is mounted to path '/login/authenticate' and the application is deployed to web application context '/myapp' your page will be available at
>>>
>>> /myapp/login/authenticate
>>>
>>> and the css in src/main/webapp/styles.css must be referenced from your page via
>>>
>>> 1) ../../css/styles.css
>>>
>>> or
>>>
>>> 2) /myapp/css/styles.css
>>>
>>> 1) is bad since the IDE is not capable of tracking the resources referenced from your markup. also changing your page mount can easily break your page.
>> Actually you just have to use "css/styles.css" and Wicket will
>> "relativize" it for you.
>> There is a special IMarkupFilter for that.
>>> 2) is bad since changing the deployment context name will break your app. also you need to know the deploment context name.
>>>
>>> when using resources in packages all these issues will not affect you at all.
>>>
>>> the 'magic' you talk about is probably not using <wicket:link>. In that case the link is unchanged (wicket does not even touch that link) and will work when you mount your pages to urls being not deeper than one level
>>>
>>> e.g. /login, /logout, /foobar
>>>
>>> it will not work with nested urls or url's that contain indexed parameters
>>>
>>> e.g. /user/id/123
>>>
>>> Am 27.07.2011 um 14:31 schrieb Peter Karich:
>>>
>>>> Am 27.07.2011 14:21, schrieb Peter Ertl:
>>>>> 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*
>>>>
>>>> no, you can just reference them via css/style.css eg. if you have
>>>> src/main/webapp/css
>>>> and wicket will do the magic for you...
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>
>
>
> ---------------------------------------------------------------------
> 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: Static Files (CSS, JPG) not Found by Wicket in HTML

Posted by Peter Ertl <pe...@gmx.org>.
> Actually you just have to use "css/styles.css" and Wicket will
> "relativize" it for you.
> There is a special IMarkupFilter for that.

but only if wrap it inside <wicket:link> 

this will not work for resources in src/main/webapp but only for package resources

without <wicket:link> the markup will just be rendered as-is and wicket will not even touch it. this is the standard behavior for static html with hrefs.

Am 27.07.2011 um 15:40 schrieb Martin Grigorov:

> On Wed, Jul 27, 2011 at 3:54 PM, Peter Ertl <pe...@gmx.org> wrote:
>> if your login page is mounted to path '/login/authenticate' and the application is deployed to web application context '/myapp' your page will be available at
>> 
>> /myapp/login/authenticate
>> 
>> and the css in src/main/webapp/styles.css must be referenced from your page via
>> 
>> 1) ../../css/styles.css
>> 
>> or
>> 
>> 2) /myapp/css/styles.css
>> 
>> 1) is bad since the IDE is not capable of tracking the resources referenced from your markup. also changing your page mount can easily break your page.
> Actually you just have to use "css/styles.css" and Wicket will
> "relativize" it for you.
> There is a special IMarkupFilter for that.
>> 2) is bad since changing the deployment context name will break your app. also you need to know the deploment context name.
>> 
>> when using resources in packages all these issues will not affect you at all.
>> 
>> the 'magic' you talk about is probably not using <wicket:link>. In that case the link is unchanged (wicket does not even touch that link) and will work when you mount your pages to urls being not deeper than one level
>> 
>> e.g. /login, /logout, /foobar
>> 
>> it will not work with nested urls or url's that contain indexed parameters
>> 
>> e.g. /user/id/123
>> 
>> Am 27.07.2011 um 14:31 schrieb Peter Karich:
>> 
>>> Am 27.07.2011 14:21, schrieb Peter Ertl:
>>>> 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*
>>> 
>>> no, you can just reference them via css/style.css eg. if you have
>>> src/main/webapp/css
>>> and wicket will do the magic for you...
>>> 
>>> ---------------------------------------------------------------------
>>> 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
> 


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


Re: Static Files (CSS, JPG) not Found by Wicket in HTML

Posted by Martin Grigorov <mg...@apache.org>.
On Wed, Jul 27, 2011 at 3:54 PM, Peter Ertl <pe...@gmx.org> wrote:
> if your login page is mounted to path '/login/authenticate' and the application is deployed to web application context '/myapp' your page will be available at
>
> /myapp/login/authenticate
>
> and the css in src/main/webapp/styles.css must be referenced from your page via
>
> 1) ../../css/styles.css
>
> or
>
> 2) /myapp/css/styles.css
>
> 1) is bad since the IDE is not capable of tracking the resources referenced from your markup. also changing your page mount can easily break your page.
Actually you just have to use "css/styles.css" and Wicket will
"relativize" it for you.
There is a special IMarkupFilter for that.
> 2) is bad since changing the deployment context name will break your app. also you need to know the deploment context name.
>
> when using resources in packages all these issues will not affect you at all.
>
> the 'magic' you talk about is probably not using <wicket:link>. In that case the link is unchanged (wicket does not even touch that link) and will work when you mount your pages to urls being not deeper than one level
>
> e.g. /login, /logout, /foobar
>
> it will not work with nested urls or url's that contain indexed parameters
>
> e.g. /user/id/123
>
> Am 27.07.2011 um 14:31 schrieb Peter Karich:
>
>> Am 27.07.2011 14:21, schrieb Peter Ertl:
>>> 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*
>>
>> no, you can just reference them via css/style.css eg. if you have
>> src/main/webapp/css
>> and wicket will do the magic for you...
>>
>> ---------------------------------------------------------------------
>> 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: Static Files (CSS, JPG) not Found by Wicket in HTML

Posted by Peter Ertl <pe...@gmx.org>.
if your login page is mounted to path '/login/authenticate' and the application is deployed to web application context '/myapp' your page will be available at

/myapp/login/authenticate

and the css in src/main/webapp/styles.css must be referenced from your page via

1) ../../css/styles.css

or 

2) /myapp/css/styles.css

1) is bad since the IDE is not capable of tracking the resources referenced from your markup. also changing your page mount can easily break your page.
2) is bad since changing the deployment context name will break your app. also you need to know the deploment context name.

when using resources in packages all these issues will not affect you at all.

the 'magic' you talk about is probably not using <wicket:link>. In that case the link is unchanged (wicket does not even touch that link) and will work when you mount your pages to urls being not deeper than one level

e.g. /login, /logout, /foobar

it will not work with nested urls or url's that contain indexed parameters

e.g. /user/id/123

Am 27.07.2011 um 14:31 schrieb Peter Karich:

> Am 27.07.2011 14:21, schrieb Peter Ertl:
>> 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*
> 
> no, you can just reference them via css/style.css eg. if you have
> src/main/webapp/css
> and wicket will do the magic for you...
> 
> ---------------------------------------------------------------------
> 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: Static Files (CSS, JPG) not Found by Wicket in HTML

Posted by Peter Karich <pe...@yahoo.de>.
 Am 27.07.2011 14:21, schrieb Peter Ertl:
> 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*

no, you can just reference them via css/style.css eg. if you have
src/main/webapp/css
and wicket will do the magic for you...

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


Re: Static Files (CSS, JPG) not Found by Wicket in HTML

Posted by Peter Ertl <pe...@gmx.org>.
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:eugenebalt@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-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
> 


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


RE: Static Files (CSS, JPG) not Found by Wicket in HTML

Posted by "Miroslav F." <mi...@seznam.cz>.
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:eugenebalt@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-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