You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tim Van Meerbeeck <ti...@gmail.com> on 2012/11/24 21:36:14 UTC

set favicon.ico dynamically in wicket 6

Hi

I got a question about wicket 6 and adding a favicon.ico:

I am trying to use a StringHeaderItem but I want the favicon.ico to be in
the resources folder (normal page:
http://localhost/whatever/page?0standard wicket resource directory:
http://localhost/whatever/resources/*). I think I should use a
ContextRelativeResource to point to the favico but you can'( point that in
stringheaderitem.

I am looking at the best way to do this in Wicket 6 and above. for earlier
versions of wicket I found some things on the net but version 6 changed
things around and I suppose this will be easy but I can't find it.

Any help is appreciated

Tim Van Meerbeeck

Re: set favicon.ico dynamically in wicket 6

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Is 'resources' folder next to WEB-INF folder in the file system ?
If YES then all you need to do is:

MyPage.html
<html>
  <head>
     <link rel="shortcut icon" href="resources/favicon.png"
type="image/png"/>
....

Wicket automatically resolves such relative urls to context relative ones
no matter what is the mount point of your page



On Sat, Nov 24, 2012 at 9:36 PM, Tim Van Meerbeeck <ti...@gmail.com> wrote:

> Hi
>
> I got a question about wicket 6 and adding a favicon.ico:
>
> I am trying to use a StringHeaderItem but I want the favicon.ico to be in
> the resources folder (normal page:
> http://localhost/whatever/page?0standard wicket resource directory:
> http://localhost/whatever/resources/*). I think I should use a
> ContextRelativeResource to point to the favico but you can'( point that in
> stringheaderitem.
>
> I am looking at the best way to do this in Wicket 6 and above. for earlier
> versions of wicket I found some things on the net but version 6 changed
> things around and I suppose this will be easy but I can't find it.
>
> Any help is appreciated
>
> Tim Van Meerbeeck
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: set favicon.ico dynamically in wicket 6

Posted by Martin Grigorov <mg...@apache.org>.
You can add components which are in the <head>.

MyPage.html:
<html>
  <head>
     <link wicket:id="favicon" ..../>
  ...
</head>
.....

MyPage.java:
....
add(new Favicon("favicon"));
....


Favicon.java:

public class Favicon extends WebComponent {

   public Favicon(String id){
     super(id);
   }

   public void onInitialize()
  {
     super.onInitialize();

     add(AttributeModifier.replace("href", generateHref(getPage())))
  }
.....
}


On Sun, Nov 25, 2012 at 7:08 PM, Tim Van Meerbeeck <ti...@gmail.com> wrote:

> Rob,
>
> This is a solution if you want to achieve this! I was just looking into the
> possibility because this is a pretty rare scenario. The favico was designed
> to have a bookmark to a site and have an icon in your favorites so you can
> quickly find the right bookmark. So the scenario to load this dynamically
> (for example for every different bookmarkable page in a wicket application,
> a different favico) is not so common.
>
> Though I had expected to find something in the standard wicket but yeah the
> scenario is quite uncommon. And with overriding this was implemented by
> you.
>
>
> Kind regards,
>
> Tim Van Meerbeeck
>
>
> 2012/11/25 Rob Schroeder <sc...@gmail.com>
>
> > Hi Tim,
> >
> > I ran into the same question a couple of days ago, and in what maybe
> > constitutes overkill for a simpler solution I didn't see, I looked at
> > CssResourceReference and reused as much of the code as seemed to be
> > necessary to make a FaviconResourceReference:
> >
> >
> https://docs.google.com/uc?export=download&id=0B3dKFXxMXAj1dWpCVUJqYzNJYUk
> >
> > With it, you can put your favicon.ico where you said you would, create a
> >
> >   FaviconResourceReference feedReaderFavicon = new
> FaviconResourceReference
> >       (FeedReader.class, "resources/favicon.ico");
> >
> > and add
> >
> >
> >
> response.render(FaviconReferenceHeaderItem.forReference(feedReaderFavicon));
> >
> > to your page's (overridden) renderHead method, just as you would with a
> > page-specific CSS resource.
> >
> > Cheers,
> > Robert
> >
> >
> > On Sat, 24 Nov 2012 21:36:14 +0100, Tim Van Meerbeeck wrote:
> >
> > > Hi
> > >
> > > I got a question about wicket 6 and adding a favicon.ico:
> > >
> > > I am trying to use a StringHeaderItem but I want the favicon.ico to be
> in
> > > the resources folder (normal page:
> > > http://localhost/whatever/page?0standard wicket resource directory:
> > > http://localhost/whatever/resources/*). I think I should use a
> > > ContextRelativeResource to point to the favico but you can'( point that
> > in
> > > stringheaderitem.
> > >
> > > I am looking at the best way to do this in Wicket 6 and above. for
> > earlier
> > > versions of wicket I found some things on the net but version 6 changed
> > > things around and I suppose this will be easy but I can't find it.
> > >
> > > Any help is appreciated
> > >
> > > Tim Van Meerbeeck
> > >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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 <http://jweekend.com/>

Re: set favicon.ico dynamically in wicket 6

Posted by Tim Van Meerbeeck <ti...@gmail.com>.
Rob,

This is a solution if you want to achieve this! I was just looking into the
possibility because this is a pretty rare scenario. The favico was designed
to have a bookmark to a site and have an icon in your favorites so you can
quickly find the right bookmark. So the scenario to load this dynamically
(for example for every different bookmarkable page in a wicket application,
a different favico) is not so common.

Though I had expected to find something in the standard wicket but yeah the
scenario is quite uncommon. And with overriding this was implemented by you.


Kind regards,

Tim Van Meerbeeck


2012/11/25 Rob Schroeder <sc...@gmail.com>

> Hi Tim,
>
> I ran into the same question a couple of days ago, and in what maybe
> constitutes overkill for a simpler solution I didn't see, I looked at
> CssResourceReference and reused as much of the code as seemed to be
> necessary to make a FaviconResourceReference:
>
> https://docs.google.com/uc?export=download&id=0B3dKFXxMXAj1dWpCVUJqYzNJYUk
>
> With it, you can put your favicon.ico where you said you would, create a
>
>   FaviconResourceReference feedReaderFavicon = new FaviconResourceReference
>       (FeedReader.class, "resources/favicon.ico");
>
> and add
>
>
> response.render(FaviconReferenceHeaderItem.forReference(feedReaderFavicon));
>
> to your page's (overridden) renderHead method, just as you would with a
> page-specific CSS resource.
>
> Cheers,
> Robert
>
>
> On Sat, 24 Nov 2012 21:36:14 +0100, Tim Van Meerbeeck wrote:
>
> > Hi
> >
> > I got a question about wicket 6 and adding a favicon.ico:
> >
> > I am trying to use a StringHeaderItem but I want the favicon.ico to be in
> > the resources folder (normal page:
> > http://localhost/whatever/page?0standard wicket resource directory:
> > http://localhost/whatever/resources/*). I think I should use a
> > ContextRelativeResource to point to the favico but you can'( point that
> in
> > stringheaderitem.
> >
> > I am looking at the best way to do this in Wicket 6 and above. for
> earlier
> > versions of wicket I found some things on the net but version 6 changed
> > things around and I suppose this will be easy but I can't find it.
> >
> > Any help is appreciated
> >
> > Tim Van Meerbeeck
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: set favicon.ico dynamically in wicket 6

Posted by Rob Schroeder <sc...@gmail.com>.
Hi Tim,

I ran into the same question a couple of days ago, and in what maybe 
constitutes overkill for a simpler solution I didn't see, I looked at 
CssResourceReference and reused as much of the code as seemed to be 
necessary to make a FaviconResourceReference: 

https://docs.google.com/uc?export=download&id=0B3dKFXxMXAj1dWpCVUJqYzNJYUk

With it, you can put your favicon.ico where you said you would, create a

  FaviconResourceReference feedReaderFavicon = new FaviconResourceReference
      (FeedReader.class, "resources/favicon.ico");

and add

  response.render(FaviconReferenceHeaderItem.forReference(feedReaderFavicon));

to your page's (overridden) renderHead method, just as you would with a 
page-specific CSS resource.

Cheers,
Robert


On Sat, 24 Nov 2012 21:36:14 +0100, Tim Van Meerbeeck wrote:

> Hi
> 
> I got a question about wicket 6 and adding a favicon.ico:
> 
> I am trying to use a StringHeaderItem but I want the favicon.ico to be in
> the resources folder (normal page:
> http://localhost/whatever/page?0standard wicket resource directory:
> http://localhost/whatever/resources/*). I think I should use a
> ContextRelativeResource to point to the favico but you can'( point that in
> stringheaderitem.
> 
> I am looking at the best way to do this in Wicket 6 and above. for earlier
> versions of wicket I found some things on the net but version 6 changed
> things around and I suppose this will be easy but I can't find it.
> 
> Any help is appreciated
> 
> Tim Van Meerbeeck
> 




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