Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Dynamically <head> tags

Mario Bertschler
1 decade ago Apr 22, 2011 8:46am

Is there any possibility to dynamically set and remove <head> tags of the document? I need this to integrate the Facebook Like Button. Facebook specifies the content of the page over meta tags: http://developers.facebook.com/docs/opengraph/

e.g.

<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
<meta property="og:site_name" content="IMDb"/>
<meta property="fb:admins" content="USER_ID"/>
<meta property="og:description"
content="A group of U.S. Marines, under command of
a renegade general, take over Alcatraz and
threaten San Francisco Bay with biological
weapons."/>
...
</head>

Well, I already have my own AbstractApplicationServlet subclassed, this helps me to define the noscript tag and so forth, but now I should change the meta tags in the <head> dynamically, as every page represent different content. Thank you for your help, Vaadin is great!

Marko Grönroos
1 decade ago Apr 23, 2011 12:09pm
Mario Bertschler
1 decade ago Apr 24, 2011 2:34pm
Marko Grönroos
1 decade ago Apr 24, 2011 3:09pm
Yuri Dirickson
1 decade ago Oct 17, 2012 10:24pm
Janis Pütz
6 years ago Nov 08, 2016 3:07pm

Is it it possible to get the fragment part when servletInitialized() gets called? So from the first request when the page gets accessed first?
Or is there a better way to set/change meta-tags nowadays, since the topic is already 6 years old?

Janis Pütz
6 years ago Nov 22, 2016 8:53pm
Marco Collovati
6 years ago Nov 22, 2016 9:11pm
Janis Pütz
6 years ago Nov 23, 2016 9:31pm
Marco Collovati
6 years ago Nov 23, 2016 9:51pm
Janis Pütz
6 years ago Nov 24, 2016 2:51am
Marco Collovati
6 years ago Nov 24, 2016 8:49am
Janis Pütz
6 years ago Nov 25, 2016 12:31am
Marco Collovati
6 years ago Nov 25, 2016 8:13am

Did you take a look at Volga addon ? (I'm pretty sure you already did it :) )

Used with History addon your SPA will have URLs like http://ocalhost:8080/show/id (instead of using fragments) so they can be parsed at server side.

If it does not fill your requirments it can always be a good starting point.
If this don't work for you I've no further ideas :)

HTH
Marco
 

Janis Pütz
6 years ago Nov 28, 2016 12:21am