Differences between revisions 7 and 8
Revision 7 as of 2009-05-24 18:37:12
Size: 1319
Editor: AdrianMurray
Comment: Fixed incorrect path
Revision 8 as of 2009-09-20 23:20:47
Size: 1319
Editor: localhost
Comment: converted to 1.6 markup
No differences found!
  • Assets should be stored along with the page you are creating.
  • General resources (CSS, JS, and images should be put in (you could try other spots, but I had trouble finding them with Jetty)
    • src/main/webapp/css
    • src/main/webapp/js
    • src/main/webapp/images
  • In case of CSS/JS/images for components, have a look into the way the T5 Grid or Palette component is constructed, since they have their own js, css and images.

[Thanks go to Daniel Jue, who answered my question on June 7, 2007]

For example, if you have this file:

src/main/webapp/css/MyStyle.css

You can access it in your page or component Java class like this:

@Inject
@Path("context:css/MyStyle.css")
private Asset thestyle;

public Asset getTheStyle() { return thestyle; }

And then in your page or component template:

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<head>
<title>My Title</title>
<link rel="stylesheet" type="text/css" href="${thestyle}"/>
</head>
...
</html>

Similarly, having src/main/webapp/images/MyLogo.gif Page or Component Class:

@Inject
@Path("context:images/MyLogo.gif")
private Asset thelogo;

public Asset getTheLogo() { return theLogo; }

Page or Component Template (the html):

<img src="${thelogo}" />

Tapestry5WhereToStoreExternalResources (last edited 2009-09-20 23:20:47 by localhost)