One more note .. if that is awkard for you ... write a one-liner
component to take care of this for you!

On Dec 5, 2007 8:06 AM, Howard Lewis Ship <[EMAIL PROTECTED]> wrote:
> This should work:
>
> <img src="${asset:context:images/some_image.gif}"/>
>
>
> The value inside a ${...} expansion is actual a binding in disguise,
> so it can use binding prefixes such as "prop:" (the default),
> "message:" or "asset:".
>
> However, inside a template, the "current location" is on the classpath
> (i.e., relative to your component's Java class file), so you have to
> specify "context:" to have the path interpreted as relative to the web
> application root.  It seems a little odd when the template file is
> itself in the web root, but I opted for a rule that is consistent
> across application pages, components and pages in libraries.
>
>
>
> On Dec 4, 2007 6:39 PM, Jean-Philippe Steinmetz <[EMAIL PROTECTED]> wrote:
> > I can't use absolute URLs because I can't make any assumptions about the
> > server environment this will run on. The server will likely vary and even
> > the context name may change. Also, using an old-fashioned relative URL
> > doesn't work for me either since my app is broken up into packages. So I may
> > have page URLs that look like /MyApp/Section/Page1 or /MyApp/MainMenu.
> >
> > Jean-Philippe
> >
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > > On Behalf Of Josh Canfield
> > > Sent: Tuesday, December 04, 2007 5:17 PM
> > > To: Tapestry users
> > > Subject: Re: [T5] Obtaining a relative directory path
> > >
> > > If these are just static images in a directory in your webapp
> > > then you don't need the functionality of an Asset for that.
> > > How about just doing it the old fashioned way?
> > >
> > > <img src="/images/some_image.jpg"/>
> > >
> > > Most of my images are done like this... sometimes I need an
> > > absolute url and I prepend that.
> > >
> > > Josh
> > > On Dec 4, 2007 4:45 PM, Jean-Philippe Steinmetz
> > > <[EMAIL PROTECTED]> wrote:
> > >
> > > > Hello all,
> > > >
> > > > I am trying to create a getter that returns the relative
> > > path to the
> > > > images directory for my application. I want it to apply in template
> > > > HTML files
> > > > as:
> > > >
> > > >    <img src="${imagesBase}/some_image.jpg"/>
> > > >
> > > > I found a previous thread (
> > > >
> > > >
> > > http://www.nabble.com/T5-How-to-difine-dynamic-path-for-image-t4834269
> > > > .html
> > > > ) on how to do this using AssetSource but this did not work
> > > for me as
> > > > it requires the java class to know the exact resource
> > > location. This
> > > > isn't beneficial when work is passed on to web designers who do not
> > > > have any programming experience, nor should have to.
> > > >
> > > > I have also tried the following java code but I keep
> > > getting runtime
> > > > errors
> > > >
> > > >    @Inject
> > > >    @Path("context:images")
> > > >    private Asset imagesBase;
> > > >
> > > >    public Asset getImagesBase() { return imagesBase; }
> > > >
> > > > Any help on this would be great. Thanks.
> > > >
> > > > Jean-Philippe Steinmetz
> > > >
> > >
> > >
> > >
> > > --
> > > --
> > > TheDailyTube.com. Sign up and get the best new videos on the
> > > internet delivered fresh to your inbox.
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
>
> --
> Howard M. Lewis Ship
> TWD Consulting, Inc.
>
> Creator Apache Tapestry and Apache HiveMind
>



-- 
Howard M. Lewis Ship
TWD Consulting, Inc.

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to