There is a ClasspathAssetFactory and a ContextAssetFactory. A useful addition to the framework would be a FilesystemAssetFactory. I am going to fill an JIRA issue about it.

The way I did it for classpath resources was very simple, see below. Only the first two lines of renderIcon() are relevant for construction an asset.

  @BeginRender
   public void renderIcon(MarkupWriter writer) {

       Resource iconResource = new ClasspathResource(BASE_PATH + src);
if(assetFactory == null) {
           LOG.warn("assertFactory is null");
       }
if(iconResource == null) {
           LOG.warn("iconResource is null");
       }
       Asset icon = assetFactory.createAsset(iconResource);

       if(icon != null) {

           writer.element("img",
               "src", icon.toClientURL(),
               "alt", getAlt());

           resources.renderInformalParameters(writer);

           writer.end();

       } else {

           writer.writeRaw(getAlt());

       }

   }



   @Inject @ClasspathProvider
   private AssetFactory assetFactory;

   @BeginRender
   public void renderIcon(MarkupWriter writer) {

       Resource iconResource = new ClasspathResource(BASE_PATH + src);
      Asset icon = assetFactory.createAsset(iconResource);

       if(icon != null) {

           writer.element("img",
               "src", icon.toClientURL(),
               "alt", getAlt());

           resources.renderInformalParameters(writer);

           writer.end();

       } else {

           writer.writeRaw(getAlt());

       }

   }








Peter Kanze schrieb:
The documentation (http://tapestry.apache.org/tapestry5/guide/assets.html)
tells me to define a new AssetFactory and contribute it to the AssetSource
service configuration.
Yes okay, but how do I implement an AssetFactory? Is there any
documentation?

What do I need to do with public Resource getRootResource() and public Asset
createAsset(Resource resource);
I also looked at ClasspathAssetFactory but don't understand it. The comment
is too minimal.

Can someone help me with this?

Thanks,
Peter!

On Tue, Mar 10, 2009 at 1:59 PM, Peter Kanze <peterka...@gmail.com> wrote:

Oke thank you.

But how do I map between the web http:// and the file D:/ urls?
Can you give me some (pseudo) code examples how to do this?

Thanks!
Peter




On Tue, Mar 10, 2009 at 1:56 PM, Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:

On Tue, Mar 10, 2009 at 9:51 AM, Peter Kanze <peterka...@gmail.com>
wrote:
I already searched the archive and found the question, but it is not
clear
to me.
There are no examples in it with a dynamic path..
You'll use AssetSource for that.

--
Thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to