You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Joe Trewin <jo...@canfactory.com> on 2005/08/31 13:58:47 UTC

Creating an IAsset in code from a context image

Hi,

I'm tring to do a very simple thing, so I'm obviously missing something
here (using Tapestry 4).

I have a method which needs to return an IAsset that points to an image
(assume located somewhere in the web context) based on some other
parameters. The method is passed the component that requires the asset.

I don't want the asset to be formally declared via a component or page
specification file, as it's determined on the fly.

How do I do this?

I've seen hints that point towards using ContextAsset in some way, but
can not find an obvious way to create one (the constructor takes
parameters that I don't know how to obtain, ie.
"org.apache.hivemind.Resource" and "org.apache.hivemind.Location").
Likewise with the 'ContextAssetFactory', although I'm not sure if that's
designed to be used outside of the core of Tapestry.

Seems simple enough, but ...

Any help gratefully recieved.

(NB. If the code needed to reference an image stored somewhere on the
classpath would this be a "private asset". If so, how might the code
change?)

Joe

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Creating an IAsset in code from a context image

Posted by Geoff Longman <gl...@gmail.com>.
public IAsset createAsset(ServletContext context, String path) {
  return new ContextAsset( new ContextResourceLocation(context, path), null);
}

there you go.

Geoff

On 8/31/05, Joe Trewin <jo...@canfactory.com> wrote:
> Hi,
> 
> I'm tring to do a very simple thing, so I'm obviously missing something
> here (using Tapestry 4).
> 
> I have a method which needs to return an IAsset that points to an image
> (assume located somewhere in the web context) based on some other
> parameters. The method is passed the component that requires the asset.
> 
> I don't want the asset to be formally declared via a component or page
> specification file, as it's determined on the fly.
> 
> How do I do this?
> 
> I've seen hints that point towards using ContextAsset in some way, but
> can not find an obvious way to create one (the constructor takes
> parameters that I don't know how to obtain, ie.
> "org.apache.hivemind.Resource" and "org.apache.hivemind.Location").
> Likewise with the 'ContextAssetFactory', although I'm not sure if that's
> designed to be used outside of the core of Tapestry.
> 
> Seems simple enough, but ...
> 
> Any help gratefully recieved.
> 
> (NB. If the code needed to reference an image stored somewhere on the
> classpath would this be a "private asset". If so, how might the code
> change?)
> 
> Joe
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
The Spindle guy.           http://spindle.sf.net
Get help with Spindle:   
http://lists.sourceforge.net/mailman/listinfo/spindle-user
Announcement Feed:    
http://www.jroller.com/rss/glongman?catname=/Announcements
Feature Updates:            http://spindle.sf.net/updates

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org