Injecting the asset as you've done doesn't make a lot of sense since the annotation @Path is a compile time construct. So what you are getting in your annotation is probably null, or whatever your default for weatherPath was.
The advantage to using AssetResource is that you can look up assets at runtime... Josh On Nov 19, 2007 5:34 AM, Chris Lewis <[EMAIL PROTECTED]> wrote: > I've not seen AssetResource - what is the advantage to using it like > this as opposed simply to injecting the asset? > > lasitha wrote: > > On Nov 19, 2007 2:37 PM, Doublel <[EMAIL PROTECTED]> wrote: > > > >> public void onActivate(String id){ > >> if (lw.hnSunny.equals(bc.getLogWeather())){ > >> this.weatherPath="logweath.gif"; > >> ... > >> @Inject > >> @Path("context:/images/"+ weatherPath ) > >> private Asset trackback; > >> > >> I want to implement image can dynamic by var weatherPath > >> > > > > Hello, i'd try injecting the AssetSource service directly into your > > page/component and using it to look up the resource dynamically. > > > http://tapestry.apache.org/tapestry5/tapestry-core/apidocs/org/apache/tapestry/services/AssetSource.html > > > > I haven't tested this, but something like: > > > > @Inject ComponentResources resources; > > @Inject AssetSource assetSource; > > > > Asset getTrackback() { > > return assetSource.findAsset( > > resources.getBaseResource(), > > "context:/images/" + calculateWeatherPath(), > > null); > > } > > > > It actually may work with just null for the first parameter (the > > resource base) too. > > > > Cheers, > > lasitha > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > -- -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox.