Reputation: 3056
The solution here helps me get absolute path to assets in class-path (context) Tapestry 5 - Dynamically generate URL of file in web app context folder in Java code
Is there a way to do the same for assets stored in META-INF/assets (Tapestry 5.4 way of storing assets)?
Specifically, I'd like to inject the path of the a .html (static) file I've created in META-INF/assets folder..
at the moment I have:
public String getMyHtml() {
String clientURL = assetSource.getContextAsset("html/myhtml.html", locale).toClientURL();
return clientURL;
}
and the tml file has:
"{ url: '${getDeltaHtml()}' }"
This works if "myhtml.html"
file is located in class path folder (WEB-INF). It does not work if its in META-INF/assets folder, which is where I'd like to put it
Upvotes: 1
Views: 1153
Reputation: 46
You can get hold of the assets stored under assets by this.
First you have to inject the following.
@Inject
private AssetSource assetSource;
@Inject
private ThreadLocale threadLocale;
After that you can use the following to get the Assets.
Asset asset = assetSource.getAsset(null, "classpath:META-INF/assets/myhtml.html", threadLocale.getLocale());
Upvotes: 2