You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Inge Solvoll <in...@gmail.com> on 2008/08/06 15:33:06 UTC
T5: Dynamic asset path
Hi!
I would like to do something like this, but this syntax obviously doesn't
work. The ${bannerPath} seems to be pointing to a "symbol", which obviously
isn't a page property.
Is there a similar way to do this?
@Inject
@Path("${bannerPath}")
private Asset banner;
public String getBannerPath() {
return "context:/company/1/banner.gif";
}
Re: T5: Dynamic asset path
Posted by Inge Solvoll <in...@gmail.com>.
Also, I can't seem to find out how to reference this asset in the .tml.
Tried a lot similar to this, nothing worked:
<img src="asset:banner"/>
Also tried annotating "private Asset banner" with @Property, no diffference.
The only thing I got working is this: <img
src="asset:context:company/1/img/banner.gif"/>
But this doesn't work for me, becuse I need to compute each customers image
path on each request.
On Wed, Aug 6, 2008 at 3:33 PM, Inge Solvoll <in...@gmail.com>wrote:
> Hi!
>
> I would like to do something like this, but this syntax obviously doesn't
> work. The ${bannerPath} seems to be pointing to a "symbol", which obviously
> isn't a page property.
> Is there a similar way to do this?
>
> @Inject
> @Path("${bannerPath}")
> private Asset banner;
>
>
> public String getBannerPath() {
> return "context:/company/1/banner.gif";
> }
>
Re: T5: Dynamic asset path
Posted by Inge Solvoll <in...@gmail.com>.
This kinda looks like something I asked for a while ago, here:
http://www.mail-archive.com/users@tapestry.apache.org/msg27620.html
On Thu, Aug 7, 2008 at 10:51 AM, Davor Hrg <hr...@gmail.com> wrote:
> it depends on what you need,
> but you could combine the asset service to generate base path
> and add the rest programatically
>
> <img
> src="${asset:context:company}/$(company.id)/img/banner.gif"/>
>
> this way you don't need a method
>
> a component would be even better to avoid copy/paste
>
> Davor Hrg
>
> On Wed, Aug 6, 2008 at 4:14 PM, Inge Solvoll <inge.tapestry@gmail.com
> >wrote:
>
> > Thanks!
> >
> > Not the prettiest thing I ever saw, I would have preferred a more
> > straghtforward approach from the framework. I need that code pretty often
> > in
> > most of my pages. But I guess I'll manage to hide it in some utility
> > method.
> >
> > On Wed, Aug 6, 2008 at 4:00 PM, 9902468 <vi...@cerion.fi>
> wrote:
> >
> > >
> > > Hi,
> > >
> > > I did this:
> > >
> > > Java:
> > >
> > > @Inject
> > > private AssetSource assetSource;
> > >
> > > public List<Language> getLanguages(){
> > > return parameterManager.getLanguages();
> > > }
> > >
> > > @Property
> > > private Language language;
> > >
> > > public String getLanguageAsset(){
> > > Asset asset = assetSource.getAsset(null, "context:/assets/images
> > > /"+language.getLanguage()+".gif", null);
> > > return asset.toClientURL();
> > > }
> > >
> > > .tml
> > >
> > > <t:loop t:source="languages" t:value="language">
> > > <imgtag class="language_flag" alt="${language.displayName}"
> > > src="${languageAsset}"/>
> > > </t:loop>
> > >
> > > change imgtag -> img
> > >
> > >
> > > Inge Solvoll-2 wrote:
> > > >
> > > > Hi!
> > > >
> > > > I would like to do something like this, but this syntax obviously
> > doesn't
> > > > work. The ${bannerPath} seems to be pointing to a "symbol", which
> > > > obviously
> > > > isn't a page property.
> > > > Is there a similar way to do this?
> > > >
> > > > @Inject
> > > > @Path("${bannerPath}")
> > > > private Asset banner;
> > > >
> > > >
> > > > public String getBannerPath() {
> > > > return "context:/company/1/banner.gif";
> > > > }
> > > >
> > > >
> > >
> > > --
> > > View this message in context:
> > >
> http://www.nabble.com/T5%3A-Dynamic-asset-path-tp18851298p18851830.html
> > > Sent from the Tapestry - User mailing list archive at Nabble.com.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
>
Re: T5: Dynamic asset path
Posted by Davor Hrg <hr...@gmail.com>.
it depends on what you need,
but you could combine the asset service to generate base path
and add the rest programatically
<img
src="${asset:context:company}/$(company.id)/img/banner.gif"/>
this way you don't need a method
a component would be even better to avoid copy/paste
Davor Hrg
On Wed, Aug 6, 2008 at 4:14 PM, Inge Solvoll <in...@gmail.com>wrote:
> Thanks!
>
> Not the prettiest thing I ever saw, I would have preferred a more
> straghtforward approach from the framework. I need that code pretty often
> in
> most of my pages. But I guess I'll manage to hide it in some utility
> method.
>
> On Wed, Aug 6, 2008 at 4:00 PM, 9902468 <vi...@cerion.fi> wrote:
>
> >
> > Hi,
> >
> > I did this:
> >
> > Java:
> >
> > @Inject
> > private AssetSource assetSource;
> >
> > public List<Language> getLanguages(){
> > return parameterManager.getLanguages();
> > }
> >
> > @Property
> > private Language language;
> >
> > public String getLanguageAsset(){
> > Asset asset = assetSource.getAsset(null, "context:/assets/images
> > /"+language.getLanguage()+".gif", null);
> > return asset.toClientURL();
> > }
> >
> > .tml
> >
> > <t:loop t:source="languages" t:value="language">
> > <imgtag class="language_flag" alt="${language.displayName}"
> > src="${languageAsset}"/>
> > </t:loop>
> >
> > change imgtag -> img
> >
> >
> > Inge Solvoll-2 wrote:
> > >
> > > Hi!
> > >
> > > I would like to do something like this, but this syntax obviously
> doesn't
> > > work. The ${bannerPath} seems to be pointing to a "symbol", which
> > > obviously
> > > isn't a page property.
> > > Is there a similar way to do this?
> > >
> > > @Inject
> > > @Path("${bannerPath}")
> > > private Asset banner;
> > >
> > >
> > > public String getBannerPath() {
> > > return "context:/company/1/banner.gif";
> > > }
> > >
> > >
> >
> > --
> > View this message in context:
> > http://www.nabble.com/T5%3A-Dynamic-asset-path-tp18851298p18851830.html
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
Re: T5: Dynamic asset path
Posted by Inge Solvoll <in...@gmail.com>.
Thanks!
Not the prettiest thing I ever saw, I would have preferred a more
straghtforward approach from the framework. I need that code pretty often in
most of my pages. But I guess I'll manage to hide it in some utility method.
On Wed, Aug 6, 2008 at 4:00 PM, 9902468 <vi...@cerion.fi> wrote:
>
> Hi,
>
> I did this:
>
> Java:
>
> @Inject
> private AssetSource assetSource;
>
> public List<Language> getLanguages(){
> return parameterManager.getLanguages();
> }
>
> @Property
> private Language language;
>
> public String getLanguageAsset(){
> Asset asset = assetSource.getAsset(null, "context:/assets/images
> /"+language.getLanguage()+".gif", null);
> return asset.toClientURL();
> }
>
> .tml
>
> <t:loop t:source="languages" t:value="language">
> <imgtag class="language_flag" alt="${language.displayName}"
> src="${languageAsset}"/>
> </t:loop>
>
> change imgtag -> img
>
>
> Inge Solvoll-2 wrote:
> >
> > Hi!
> >
> > I would like to do something like this, but this syntax obviously doesn't
> > work. The ${bannerPath} seems to be pointing to a "symbol", which
> > obviously
> > isn't a page property.
> > Is there a similar way to do this?
> >
> > @Inject
> > @Path("${bannerPath}")
> > private Asset banner;
> >
> >
> > public String getBannerPath() {
> > return "context:/company/1/banner.gif";
> > }
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-Dynamic-asset-path-tp18851298p18851830.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: T5: Dynamic asset path
Posted by 9902468 <vi...@cerion.fi>.
Hi,
I did this:
Java:
@Inject
private AssetSource assetSource;
public List<Language> getLanguages(){
return parameterManager.getLanguages();
}
@Property
private Language language;
public String getLanguageAsset(){
Asset asset = assetSource.getAsset(null, "context:/assets/images
/"+language.getLanguage()+".gif", null);
return asset.toClientURL();
}
.tml
<t:loop t:source="languages" t:value="language">
<imgtag class="language_flag" alt="${language.displayName}"
src="${languageAsset}"/>
</t:loop>
change imgtag -> img
Inge Solvoll-2 wrote:
>
> Hi!
>
> I would like to do something like this, but this syntax obviously doesn't
> work. The ${bannerPath} seems to be pointing to a "symbol", which
> obviously
> isn't a page property.
> Is there a similar way to do this?
>
> @Inject
> @Path("${bannerPath}")
> private Asset banner;
>
>
> public String getBannerPath() {
> return "context:/company/1/banner.gif";
> }
>
>
--
View this message in context: http://www.nabble.com/T5%3A-Dynamic-asset-path-tp18851298p18851830.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org