0

I am using Wicket and I need my pages to include the profile attribute with their head element. Since Wicket takes care of rendering the actual head section it is not apparent how to do this. I need HTML like so:

<head profile="http://a9.com/-/spec/opensearch/1.1/">
    <link rel="search" type="application/opensearchdescription+xml" href="osdd.xml" title="Search"/>
</head>

For the interested reader, I am trying to advertise my web application's OpenSearch Description Document as documented here: http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document

As an aside, I find it disgruntling and bad-smelling when a trivial task like this is made so difficult by the web framework!

4

1 回答 1

3

What version of wicket are you using? In Wicket 1.4 you can add any attribute to any tag using an Behavior:

HTML:

<head wicket:id="head">
    ...
    <link rel="search" type="application/opensearchdescription+xml" href="osdd.xml" title="Search"/>
</head>

java:

add(new WebMarkupContainer("head").add(new SimpleAttributeModifier("profile"
            ,"http://a9.com/-/spec/opensearch/1.1/")));

For Wicket 1.5, the Javadoc of the above SimpleAttributeModifier tells you what to use instead.

Regards

PS: I don 't see anything difficult here. Wicket provides a few ways to contribute to the header section. I guess adding an attribute to the is a rather uncomon task.

于 2011-12-27T22:39:40.763 回答