Reputation: 5052
I am not a Java developer and forced to work with Tapestry 5.3.8. I am able to use assets like css, images and a fav icon in my web page. I do this by injecting them in my page like this:
@Inject
@Path("context:static/img/logo.png")
private Asset logo;
@Inject
@Path("context:static/img/favicon.ico")
private Asset favIcon;
This works without problems. Although it works, I am not convinced the assets are in the right folder. Should they be placed in folder 'static'?
Now I want to add a Javascript file. This is what I did:
@Import(library = "context:static/js/additional.js")
public class Master {
// ...
}
The file is found, but I runtime i get the following error: "The resource path was not within an aliased path".
From what I understand is that I need to create an alias for the path where my Javscript file is located, but how?
I guess this must be done in method "contributeClasspathAssetAliasManager" in CiAppModule.java. Is this right, and what should I add?
Upvotes: 0
Views: 676
Reputation: 5052
The problem was in this part:
@Import(library = "context:static/js/additional.js")
When I change it into
@Import(library = {"context:static/js/additional.js"})
it works.
Thanks to Tapestry's error reporting, this was not clear at all. Grrrr.
Upvotes: 0
Reputation: 27994
I've never tried to use a context:
asset for a javascript file. Tapestry makes classpath assets available under the assets/
alias which is possibly what this error is referring to. See the mention of 'asset fingerprinting' here
A possible souition is:
package foo.bar.components;
@Import(library = "additional.js")
public class Master {
And then have foo/bar/components/additional.js
available on the classpath. For maven / gradle this will mean the file lives at src/main/resources/foo/bar/components/additional.js
Upvotes: 1