Have another question about serving up CSS (JS, img, etc) files statically:
a) I'd like to have the option to serve my CSS up statically via an apache
proxy. I'd also like to avoid serving CSS requests up via the wicket filter
- even if served up by Jetty - as I think it will scale just a bit better
...
b) With my current URL mounts, many pages with different base URLs refer to
the same CSS file. Consequently, a relative URL for the common CSS files as
referenced in the master template won't work since the CSS file would be
looked up relative to each different URL mount point.
Does that makes sense? So, I would like to create a simple, absolute
reference mechanism for my static CSS, image or other files (without
hardcoding).
I'm not as knowledgeable about the way that components are mapped to wicket
tags, how to add my own tags or even how to create my own components (other
than Panels of course). Does the approach below adhere to the "wicket way"?
It feels a bit manual ... and I'm not fond of the static WEB_CONTEXT
assignment - but I don't see an elegant/efficient way to get it from within
the Page or the AbstractBehavior on a per request basis.
Just looking for a bit of advice.
Does the WIKI have some detailed docs that really get into the nitty gritty
of low-level component and tag design? IE: Details of ComponentTag,
MarkupElement, WicketTag,
On the other hand, is there any strong advice to put custom CSS, image and
JS files in the classpath and reference ala wicket or is my approach
perfectly reasonable here. An alternate goal of mine to keep custom
components/solutions to a minimum.
Thanks in advance,
-Luther
*MARKUP IN:*
<head>
<link wicket:id="head.link" rel="stylesheet"
href="style/default/main.css"/>
</head>
*MARKUP OUT:*
<head>
<link rel="stylesheet" href="*/portal/*style/default/main.css"/>
</head>
*JAVA*
final static String WEB_CONTEXT =
WebApplication.get().getServletContext().getContextPath();
protected DefaultPageTemplate()
{
//
http://www.mkyong.com/wicket/how-to-dynamic-add-attribute-to-a-html-tag-in-wicket/
final WebMarkupContainerWithAssociatedMarkup cssLink = new
WebMarkupContainerWithAssociatedMarkup("head.link");
add(cssLink);
cssLink.add(new AbstractBehavior()
{
private static final long serialVersionUID = 1L;
@Override
public void onComponentTag(final Component component,
final ComponentTag tag)
{
String href = tag.getAttribute("href");
href = WEB_CONTEXT + "/" + href;
tag.put("href", href);
}
});
}