Reputation: 3367
today I was damaging my brain for too long on how I am able in Apache wicket to access the actual filecontent of a CssResourceReference?
The CSSResourceReference is declared like that:
private final CssResourceReference CSS_GLOBAL = new CssResourceReference(BasePage.class, "css/global.css");
...and is meant to be used for basic header contribution as well as it's contents need to be accessible from within a behaviour for feeding a LessCSSEngine.
I know that I am able to get the url (via the WicketWiki):
RequestCycle.get().urlFor(CSS_GLOBAL, null);
But from there on, I am stuck on how to actually access the file and contents.
Any help appreciated.
Upvotes: 1
Views: 474
Reputation: 994
You can't access the content that easily because a ResourceReference in Wicket is meant to load by a Request. You can simulate a Request and read the response but this is too much work. Anyways you don't need Wicket to access files in your class path:
final InputStream stream = BasePage.class.getResourceAsStream("css/global.css");
final Reader reader = new InputStreamReader(stream);
Upvotes: 1