You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by davidb82 <da...@thisisnumero.com> on 2009/05/28 16:42:30 UTC

Question about AssertDispatcher and custom Assets

Hi,

I am trying to register a custom Asset type, but I seem to have confused
myself... I'm hoping somebody more intelligent than me (not hard :-)) can
help me out. 

My problem is that I don't see how to get the client urls generated by the
Assets I return from my AssetFactory to get correctly interpretted by the
AssetDispatcher/AssetResourceLocator. It seems as though there is a
hardcoded assumption that the Asset is either a servlet context resource or
on the classpath, whereas I expected the AssetResourceLocator would somehow
determine the type of the asset based on the url and retrieve the resource
by calling getRootResource() on the approrpiate AssetFactory and then
passing in the relative path to this resource supplied by the url.

Judging by the documention:
(http://tapestry.apache.org/tapestry5.1/guide/assets.html) it's possible to
create assets which are, for example, stored in a database, so I'm sure I'm
missing something obvious here.  

Hope someone can help.

Cheers

Dave

-- 
View this message in context: http://www.nabble.com/Question-about-AssertDispatcher-and-custom-Assets-tp23763175p23763175.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: Question about AssertDispatcher and custom Assets

Posted by davidb82 <da...@thisisnumero.com>.
Thanks Robert, that's a useful example.

I've implemented that and it worked well, although I do think it would be
more consistent if the framework was able to hook into the custom resource
(possibly via the AssetFactory) itself when handling the request, in the
same way as it does when generating the url. In any case, the documentation
could probably be a bit clearer in this area about what's required (it only
mentions contributing the AssetFactory to the AssetSource service) which
would have saved me some time. I realise you're not responsible for any of
that btw, just giving some feedback to any tapestry contributors who might
stumble over this.

Dave


Robert Zeigler wrote:
> 
> Take a look at:
> 
> http://tapestry.formos.com/cgi-bin/viewvc.cgi/chenillekit/branches/1.0/chenillekit-tapestry/src/main/java/org/chenillekit/tapestry/core/factories/URIAssetFactory.java?view=markup
> 
> for an example of how to create custom Assets.  But note that the  
> approach there still requires you to implement a custom dispatcher to  
> handle the custom-asset request.
> This is generally reasonable, since only you will know how to retrieve  
> the asset specified by the incoming url.
> The benefit to going the asset route is that you still have  
> opportunities for asset localization, and your assets will "snap"  
> right into the rest of the framework.
> 
> Robert
> 
> On May 28, 2009, at 5/289:42 AM , davidb82 wrote:
> 
>>
>> Hi,
>>
>> I am trying to register a custom Asset type, but I seem to have  
>> confused
>> myself... I'm hoping somebody more intelligent than me (not  
>> hard :-)) can
>> help me out.
>>
>> My problem is that I don't see how to get the client urls generated  
>> by the
>> Assets I return from my AssetFactory to get correctly interpretted  
>> by the
>> AssetDispatcher/AssetResourceLocator. It seems as though there is a
>> hardcoded assumption that the Asset is either a servlet context  
>> resource or
>> on the classpath, whereas I expected the AssetResourceLocator would  
>> somehow
>> determine the type of the asset based on the url and retrieve the  
>> resource
>> by calling getRootResource() on the approrpiate AssetFactory and then
>> passing in the relative path to this resource supplied by the url.
>>
>> Judging by the documention:
>> (http://tapestry.apache.org/tapestry5.1/guide/assets.html) it's  
>> possible to
>> create assets which are, for example, stored in a database, so I'm  
>> sure I'm
>> missing something obvious here.
>>
>> Hope someone can help.
>>
>> Cheers
>>
>> Dave
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/Question-about-AssertDispatcher-and-custom-Assets-tp23763175p23763175.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
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Question-about-custom-Asset-types-tp23763175p23776099.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: Question about AssertDispatcher and custom Assets

Posted by Robert Zeigler <ro...@scazdl.org>.
Take a look at:

http://tapestry.formos.com/cgi-bin/viewvc.cgi/chenillekit/branches/1.0/chenillekit-tapestry/src/main/java/org/chenillekit/tapestry/core/factories/URIAssetFactory.java?view=markup

for an example of how to create custom Assets.  But note that the  
approach there still requires you to implement a custom dispatcher to  
handle the custom-asset request.
This is generally reasonable, since only you will know how to retrieve  
the asset specified by the incoming url.
The benefit to going the asset route is that you still have  
opportunities for asset localization, and your assets will "snap"  
right into the rest of the framework.

Robert

On May 28, 2009, at 5/289:42 AM , davidb82 wrote:

>
> Hi,
>
> I am trying to register a custom Asset type, but I seem to have  
> confused
> myself... I'm hoping somebody more intelligent than me (not  
> hard :-)) can
> help me out.
>
> My problem is that I don't see how to get the client urls generated  
> by the
> Assets I return from my AssetFactory to get correctly interpretted  
> by the
> AssetDispatcher/AssetResourceLocator. It seems as though there is a
> hardcoded assumption that the Asset is either a servlet context  
> resource or
> on the classpath, whereas I expected the AssetResourceLocator would  
> somehow
> determine the type of the asset based on the url and retrieve the  
> resource
> by calling getRootResource() on the approrpiate AssetFactory and then
> passing in the relative path to this resource supplied by the url.
>
> Judging by the documention:
> (http://tapestry.apache.org/tapestry5.1/guide/assets.html) it's  
> possible to
> create assets which are, for example, stored in a database, so I'm  
> sure I'm
> missing something obvious here.
>
> Hope someone can help.
>
> Cheers
>
> Dave
>
> -- 
> View this message in context: http://www.nabble.com/Question-about-AssertDispatcher-and-custom-Assets-tp23763175p23763175.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


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