You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Alan Chandler <al...@chandlerfamily.org.uk> on 2005/08/14 09:35:40 UTC

Confused about asset prefix

I am confused about asset prefix, and how to use them within the annotation 
approach.  

I have seen component specifications with xml tags of the form 
<private-asset> ...
The userguide only specifies two prefixes (namely "classpath" and "context")  
in the dtd section, but doesn't mention them at all in the annotations 
centre.

Can someone explain to me which and how I should use them in the context I 
describe below.

Essentially what I am trying to do is build a component, which has image and 
style sheet assets embedded within it (in subdirectores styles and images 
relative to the component java class file).  I am seeing how far I can get 
without a component specification by using annotations in the class file.

This component will then be placed in a library.

An application that I am going to write will then use that component, and so I 
hope will get the assets served up correctly

[Longer term, I am expecting to deploy this combination on an apache2 web 
server/tomcat4.1 combination, and I would like to use the 
"org.apache.tapestry.asset.dir" and "org.apache.tapestry.asset.URL" 
configuration properties (as  <meta> tags in the the applications properties 
file?) to copy these assets to a directory which is statically served by 
apache - although since these assets are in a library, multiple applications 
on the same will be using them, so whether there there an issue with multiple 
copying of this asset is a question?]


-- 
Alan Chandler
http://www.chandlerfamily.org.uk

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


Re: Confused about asset prefix

Posted by Vjeran Marcinko <vj...@email.t-com.hr>.
----- Original Message ----- 
From: "Vjeran Marcinko" <vj...@email.t-com.hr>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Tuesday, August 16, 2005 6:39 AM
Subject: Re: Confused about asset prefix


 > NOW, please don't tell me that I have to explicitly configure Tapestry 
with
> some global path setting JUST for this thing ?! That would most surely be 
> annoying... I just want this component to reference this damn gif that is 
> packaged beside it. ;)
> <private-asset> in 3.0 worked well with this as I recall.

BTW, my component is not part of some tapestry's library as you has given in 
your example.

-Vjeran


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


Re: Confused about asset prefix

Posted by Vjeran Marcinko <vj...@email.t-com.hr>.
----- Original Message ----- 
From: "Alan Chandler" <al...@chandlerfamily.org.uk>
To: <ta...@jakarta.apache.org>
Sent: Tuesday, August 16, 2005 12:47 AM
Subject: Re: Confused about asset prefix


> All paths are relative to the context path
>
> I have a library specification at
>
> WEB-INF/classes/uk/org/chandlerfamily/tapestry/components/akc.library
>
> That simply locates that component classes at the same level thus.
>
> <library-specification>
>  <meta key="org.apache.tapestry.component-class-packages">
>  uk.org.chandlerfamily.tapestry.components
>  </meta>
> </library-specification>
>
> At this level, is my component class Border.java, I have some some assets
> defined
>
> // Style Sheet
>    @Asset("context:/styles/border.css")
>    public abstract IAsset getSiteStyle();
>
> // Heading Images
> @Asset("images/coal.png")
> public abstract IAsset getLeftHeadImg();
>
>
> The first of these is located in
>
> styles/border.css
>
> The second of these is located in
>
> WEB_INF/classes/uk/org/chandlerfamily/tapestry/components/images/coal.png
>
>
> All is working perfectly.

Here is my case....
My component's path is located at :
/WEB-INF/classes/article/crud/tapestry/MyComponent.jwc
and inside it I have:
<asset name="info" path="classpath:info-icon.gif"/>
since this .gif is located also in this same directory:
/WEB-INF/classes/article/crud/tapestry/info-icon.gif
and it raises :
java.lang.ClassCastException
    at 
org.apache.tapestry.asset.ClasspathAssetFactory.createAsset(ClasspathAssetFactory.java:46)

OK, so I thought maybe this relative location doesn't work, let's try :
<asset name="info" path="classpath:article/crud/tapestry/info-icon.gif"/>
and this time it raises different error report:
Unable to locate asset 'article/crud/tapestry/info-icon.gif' relative to 
context:/WEB-INF/classes/article/crud/tapestry/MyComponent.jwc

NOW, please don't tell me that I have to explicitly configure Tapestry with 
some global path setting JUST for this thing ?! That would most surely be 
annoying... I just want this component to reference this damn gif that is 
packaged beside it. ;)
<private-asset> in 3.0 worked well with this as I recall.

-Vjeran


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


Re: Confused about asset prefix

Posted by Alan Chandler <al...@chandlerfamily.org.uk>.
On Monday 15 Aug 2005 21:37, Vjeran Marcinko wrote:
> ----- Original Message -----
> From: "Kent Tong" <ke...@cpttm.org.mo>
> To: <ta...@jakarta.apache.org>
> Sent: Monday, August 15, 2005 7:05 PM
> Subject: Re: Confused about asset prefix
>
> > class MyComponent {
> >  @Asset("classpath:images/001.gif")
> >  public abstract IAsset getMyAsset();
> > }
> >
> > There is such an example in chapter 6 of my book (but it uses <asset>,
> > not @Asset).
>
> Dunno how you managed to do that, since I tried using "classpath" prefix in
> both beta3 and beta4, and in both versions it didn't work. I checked my
> /WEB-INF/classes/.../whatever directory, and it did contain .gif that I
> tried to reference, but it doesn't work. I tried all possible referencing,
> relative and absolute...starting with slash, and without it...
> Here's the bug report:
> http://issues.apache.org/jira/browse/TAPESTRY-412

I have been using it all evening, since I learnt about it from the previous 
post.

All paths are relative to the context path

I have a library specification at

WEB-INF/classes/uk/org/chandlerfamily/tapestry/components/akc.library

That simply locates that component classes at the same level thus.

 <library-specification>
 	<meta key="org.apache.tapestry.component-class-packages">
 		uk.org.chandlerfamily.tapestry.components
 	</meta>
 </library-specification>

At this level, is my component class Border.java, I have some some assets 
defined

// Style Sheet
    @Asset("context:/styles/border.css")
    public abstract IAsset getSiteStyle();

// Heading Images
	@Asset("images/coal.png")
	public abstract IAsset getLeftHeadImg();


The first of these is located in

styles/border.css

The second of these is located in

WEB_INF/classes/uk/org/chandlerfamily/tapestry/components/images/coal.png


All is working perfectly.




-- 
Alan Chandler
http://www.chandlerfamily.org.uk

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


Re: Confused about asset prefix

Posted by Vjeran Marcinko <vj...@email.t-com.hr>.
----- Original Message ----- 
From: "Kent Tong" <ke...@cpttm.org.mo>
To: <ta...@jakarta.apache.org>
Sent: Monday, August 15, 2005 7:05 PM
Subject: Re: Confused about asset prefix


> class MyComponent {
>  @Asset("classpath:images/001.gif")
>  public abstract IAsset getMyAsset();
> }
>
> There is such an example in chapter 6 of my book (but it uses <asset>, not
> @Asset).

Dunno how you managed to do that, since I tried using "classpath" prefix in 
both beta3 and beta4, and in both versions it didn't work. I checked my 
/WEB-INF/classes/.../whatever directory, and it did contain .gif that I 
tried to reference, but it doesn't work. I tried all possible referencing, 
relative and absolute...starting with slash, and without it...
Here's the bug report:
http://issues.apache.org/jira/browse/TAPESTRY-412

-Vjeran



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


Re: Confused about asset prefix

Posted by Alan Chandler <al...@chandlerfamily.org.uk>.
On Monday 15 Aug 2005 22:16, Adam Greene wrote:
> No, both org.apache.tapestry.asset.dir and org.apache.tapestry.asset.URL
> are still used, as of Beta 3 anyways.

Well my beta 4 version of the User Guide in the "Configuring Tapestry" section 
where it lists the configuration parameters has a little panel that says 
these two are not used any longer.

If they are still used - how would you use them?



-- 
Alan Chandler
http://www.chandlerfamily.org.uk

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


Re: Confused about asset prefix

Posted by Adam Greene <ag...@iq-2000.com>.
No, both org.apache.tapestry.asset.dir and org.apache.tapestry.asset.URL are 
still used, as of Beta 3 anyways.

----- Original Message ----- 
From: "Alan Chandler" <al...@chandlerfamily.org.uk>
To: <ta...@jakarta.apache.org>
Sent: Monday, August 15, 2005 3:54 PM
Subject: Re: Confused about asset prefix


> On Monday 15 Aug 2005 18:05, Kent Tong wrote:
> l...
>> Try:
>>
>> class MyComponent {
>>   @Asset("classpath:images/001.gif")
>>   public abstract IAsset getMyAsset();
>
>
> Thanks, I usderstand the syntax now - although it appears (from what is
> currently happening in my test app) that classpath is the default.
>
> I presume this means that I could  specify INSIDE A LIBRARY COMPONENT
>
> @Asset("context:styles/sitestyle.css")
> public abstract IAsset getSiteStyle();
>
> and then expect the user (MyApp) of the component to supply the style 
> sheet
> at /MyApp/styles/sitestyle.css
>
> As I said in the original post from this thread, I have a longer term 
> desire
> to cause these assets to be served up by apache rather than tomcat.  I 
> note
> the latest userguide says that
>
> org.apache.tapestry.asset.dir and org.apache.tapestry.asset.URL
>
> are no longer needed.  So how do I do it now? And where do "private" 
> assets
> come into it?
>
> -- 
> Alan Chandler
> http://www.chandlerfamily.org.uk
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
> 


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


Re: Confused about asset prefix

Posted by Alan Chandler <al...@chandlerfamily.org.uk>.
On Monday 15 Aug 2005 18:05, Kent Tong wrote:
l...
> Try:
>
> class MyComponent {
>   @Asset("classpath:images/001.gif")
>   public abstract IAsset getMyAsset();


Thanks, I usderstand the syntax now - although it appears (from what is 
currently happening in my test app) that classpath is the default.

I presume this means that I could  specify INSIDE A LIBRARY COMPONENT 

@Asset("context:styles/sitestyle.css")
public abstract IAsset getSiteStyle();

and then expect the user (MyApp) of the component to supply the style sheet 
at /MyApp/styles/sitestyle.css 

As I said in the original post from this thread, I have a longer term desire 
to cause these assets to be served up by apache rather than tomcat.  I note 
the latest userguide says that 

org.apache.tapestry.asset.dir and org.apache.tapestry.asset.URL

are no longer needed.  So how do I do it now? And where do "private" assets 
come into it?

-- 
Alan Chandler
http://www.chandlerfamily.org.uk

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


Re: Confused about asset prefix

Posted by Kent Tong <ke...@cpttm.org.mo>.
Alan Chandler <alan <at> chandlerfamily.org.uk> writes:

> Essentially what I am trying to do is build a component, which has image and 
> style sheet assets embedded within it (in subdirectores styles and images 
> relative to the component java class file).  I am seeing how far I can get 
> without a component specification by using annotations in the class file.
> 
> This component will then be placed in a library.

Try:

class MyComponent {
  @Asset("classpath:images/001.gif")
  public abstract IAsset getMyAsset();
}

There is such an example in chapter 6 of my book (but it uses <asset>, not
@Asset).

--
Author of an e-Book for learning Tapestry (http://www.agileskills2.org/EWDT)


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