Yes, please post this up on the wiki, it is definitely useful.
I wonder if there is some way to add this to the core tapestry. Also,
it might be clearer to add application or library wide assets, so we
just modify the .application or .library rather than the hivemodule.xml....
then we can simply go image="appasset:blah" or image="libasset:blah"..
maybe.. but then we might want an asset aliases <asset name="babble"
alias="appasset:blah"/>
just a thought.
Filip S. Adamsen wrote:
Right. So what I had in mind to begin with wasn't really feasible - and
there is a far easier way to do it:
I ended up creating a GlobalAssetFactory instead. It uses a
GlobalAssetManager backed by a GlobalAssets configuration to convert ids
to paths. The paths can contain prefixes like "classpath" and "context"
- or any other prefix contributed to Tapestry through HiveMind.
Right now, I can do this in my hivemodule:
<contribution configuration-id="example.GlobalAssets">
<asset id="logo" path="context:graphics/logo.png" />
<asset id="stylesheet" path="context:styles/default.css" />
</contribution>
And this in my component/page spec files:
<asset name="logo" path="global:logo" />
<asset name="style" path="global:stylesheet" />
Works like a charm.
If anyone is interested in the code, let me know.
-Filip
Filip S. Adamsen skrev:
Well, assuming you're on T4 (and hence have HiveMind support built-in
by default) you can do this:
1. Create a GlobalAssetManager service.
2. Create an example.globalAssets configuration-point and hand it to
the GlobalAssetManager service.
3. Create a org.apache.tapestry.binding.BindingFactory service
implementation (extend
org.apache.tapestry.binding.AbstractBindingFactory) and have it locate
the requested asset via your GlobalAssetManager service and return an
implementation of org.apache.tapestry.IBinding that returns said asset.
4. Add your GlobalAssetBindingFactory to the
tapestry.bindings.BindingFactories HiveMind configuration-point with a
prefix like "global-asset".
Something like that. Would that work for you?
I could actually use something like this for my own projects... Guess
I'll have a go at it. Let me know if you're interested in the code.
-Filip
Bode, Bianca skrev:
Hi all,
I have a lot of images on another server that need to be incorporated in
my application.
Instead of defining the external assets on every page I need them, can I
have them all in one 'properties' file and reference them from there?
Kind regards, Bianca
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]