You can read this link http://tapestry.apache.org/tapestry5/tapestry-core/guide/assets.html or this link (in chinese) http://www.javaeye.com/article/78348
Maybe you can get some idea 2007/7/24, Todd Orr <[EMAIL PROTECTED]>:
Ugh. I created a small test project and it works correctly there. Unfortunately, my real project is much larger. So, now I have the incredibly tedious task of starting a new project and adding code bit by bit until it breaks so that I can attempt to determine what is causing the failure. On 7/24/07, Nick Westgate <[EMAIL PROTECTED]> wrote: > Hi Todd. > > I just tested this, not with a template, but just writing HTML. > Details of my successful test follow, but first ... > > Are your images under the "resources" tree: > \myapp\src\main\resources\jp\co\key_planning\myapp\tapestry\components > > That's important, I think. > > My component CheckBoxImage.java > > ... > @Inject > @Path("check_checked.gif") > private Asset checkedImage; > ... > boolean beginRender(MarkupWriter writer) > { > writer.element("img", "src", _test ? checkedImage : uncheckedImage); > ... > > Turns out fine in the HTML: > <img src="/myapp/assets/jp/co/key_planning/myapp/tapestry/components/check_checked.gif"> > > And I can view the image in the browser at: > http://localhost:8080/myapp/assets/jp/co/key_planning/myapp/tapestry/components/check_checked.gif > > Cheers, > Nick. > > > Todd Orr wrote: > >> From what I see in the GridColumns code, I've coded this correctly. > > I'm still confused about why this works for a core component but not a > > custom component. Unless anyone has any insight I'll create a Jira > > item. > > > > > > On 7/20/07, Todd Orr <[EMAIL PROTECTED]> wrote: > >> Tap 5.0.5. > >> > >> I'm having trouble loading an asset from the classpath. Everywhere > >> I've looked I see that it should be dead simple. However, when I > >> attempt to view the image directly in the browser (firefox) I get: > >> > >> The image > >> "http://localhost:8080/testapp/assets/com/test/testapp/web/components/slider_default_selected.png" > >> > >> cannot be displayed, because it contains errors. > >> > >> > >> The code that injects the image is: > >> > >> @Inject > >> @Path("slider_default_selected.png") > >> //@Path("context:images/slider_default_selected.png") // testing > >> private Asset defaultSelectedImage; > >> > >> ... > >> > >> getter too. > >> > >> > >> The template code: > >> > >> <img src="${defaultSelectedImage}" /> > >> > >> > >> Has anyone run into this before? For testing the code works fine when > >> using a context relative injection. However, this is not my ideal > >> choice for packaging. > >> > >> Thanks > >> > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- 得与失都是生活