Hi,

the Javadoc of IHeaderResponse#renderString says:
"Renders an arbitrary string to the header. The string is only rendered if the same string hasn't been rendered before." So if you call it with two different titles the expected behavior is to get the title tag twice.

I wouldn't use a IHeaderResponse for that. My suggestion is to use a normal title tag in your base page markup. Provide a method which returns the current title and let specific pages override that method as needed.


Christoph



heikki (2012-05-03 15:10):
hello,

I'd like to be able to use a fixed title for my pages, that gets overridden
for some of the pages.

To do that, I have a fixed title element in my base HTML page:


Then in the pages that should have a different title, I override
renderHead() like this:

     @Override
     public void renderHead(final IHeaderResponse response) {
         String title = "<title>" + getTheDynamicTitle() +"</title>";
         response.renderString(title);
    }

The result is that my rendered page has 2<title>  elements in its header,
the fixed one and the dynamic one.

I would have thought that Wicket would be smart enough to replace an
existing header element; the IHeaderResponse javadoc says "Implementation of
this interface is responsible for filtering duplicate contributions (so that
for example the same javascript is not loaded twice) during the same
request". Well.

Do I need to write my own implementation of IHeaderResponse for this ?

It would seem like a pretty common use case to me, did anyone already solve
it ?

Kind regards
Heikki Doeleman

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-prevent-duplicates-when-using-HeaderContributor-tp4605975.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

Reply via email to