You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Ben Peter <bp...@zentropypartners.com> on 2002/03/28 08:13:06 UTC

How can a list of available templates be obtained?

All,

is there a way of obtaining a list of templates that a loader can provide?

I need to make a list of templates in a package/directory available in a drop 
down box, as they are page asset templates.

With the FileResoureceLoader, this is not a problem, as I can use the same 
directory and read from that. However, I would like to deploy the templates in 
a jar file and use the ClasspathResourceLoader.

Is there a way of finding all templates that reside, say, in 
/com/mycompany/app/templates ?

Cheers,
Ben
-- 
Benjamin Peter                                          +49-69-96244395
Application Engineer                             Moerfelder Landstr. 55
(zentropy:partners)                            60598 Frankfurt, Germany


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: OT Re: How can a list of available templates be obtained?

Posted by Attila Szegedi <sz...@freemail.hu>.
----- Original Message -----
From: "Geir Magnusson Jr." <ge...@optonline.net>
To: <ve...@jakarta.apache.org>
Sent: 2002. március 31. 20:36
Subject: Re: OT Re: How can a list of available templates be obtained?


>
> This is a funny thread for me.  I know that Attila knows how to spell it.
>

Definitely. This was just a silly typo. That said, I actually *do* imagine
"Geir" is pronounced as "gear" - I don't know for sure as I never heard
anyone's authoritative pronounciation of your name - not many Scandinavians
around here, y'know :-)

> It just took me back to gradeschool, as riffing on the 'circular
rotational
> energy transfer device' was a common theme...
>

I have some empathy for you re this; growing up in Croatia with a Hungarian
name that just sounds weird to Croatians also served as a basis for some
*very creative* mock-poems from my classmates. Not to speak of the fact that
those that met my name before actually seeing me were usually surprised that
I'm not a female when they finally met me in person; names ending with "a"
are traditionally (with only few exceptions) female names in Slavic
languages...

Cheers,
  Attila.

> :)
>
> geir
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: OT Re: How can a list of available templates be obtained?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/31/02 1:25 PM, "Anthony Eden" <ae...@signaturedomains.com> wrote:

> Gear, gear. ;-)
> 
> (as opposed to hear, hear...ok, lame joke...I'm no gear, just a tool.)

This is a funny thread for me.  I know that Attila knows how to spell it.

It just took me back to gradeschool, as riffing on the 'circular rotational
energy transfer device' was a common theme...

:)

geir

> 
> -Anthony
> 
>> -----Original Message-----
>> From: Jim Rudnicki [mailto:jdr5list@pacbell.net]
>> Sent: Sunday, March 31, 2002 2:17 AM
>> To: Velocity Users List
>> Subject: OT Re: How can a list of available templates be obtained?
>> 
>> 
>>>> not disallowed by any specification... What Gear calls
>> "large space" 
>>>> can
>> be
>> 
>>> "Geir"
>>> 
>>> :)
>> 
>> That's it!  In honor of
>> his response to almost every post no matter how confused,
>> his unflappable responses to the most inflammatory posts,
>> and his general commitment, I propose that us mere mortals spread some
>> slang:
>> 
>> Anybody does something impressive, you say
>> "you're a gear, man!"
>> or
>> "gear on"
>> 
>> Yep, give it a try.  Spread it around.
>> 
>> Jim
>> 
>> 
>> 
>> --
>> To unsubscribe, e-mail:
>> <mailto:velocity-user-> unsubscribe@jakarta.apache.org>
>> For 
>> additional commands,
>> e-mail: <ma...@jakarta.apache.org>
>> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
The bytecodes are language independent. - Sam Ruby  


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: OT Re: How can a list of available templates be obtained?

Posted by Anthony Eden <ae...@signaturedomains.com>.
Gear, gear. ;-)

(as opposed to hear, hear...ok, lame joke...I'm no gear, just a tool.)

-Anthony

> -----Original Message-----
> From: Jim Rudnicki [mailto:jdr5list@pacbell.net] 
> Sent: Sunday, March 31, 2002 2:17 AM
> To: Velocity Users List
> Subject: OT Re: How can a list of available templates be obtained?
> 
> 
> > > not disallowed by any specification... What Gear calls 
> "large space" 
> > > can
> be
> 
> > "Geir"
> >
> > :)
> 
> That's it!  In honor of
> his response to almost every post no matter how confused,
> his unflappable responses to the most inflammatory posts,
> and his general commitment, I propose that us mere mortals spread some
> slang:
> 
> Anybody does something impressive, you say
> "you're a gear, man!"
> or
> "gear on"
> 
> Yep, give it a try.  Spread it around.
> 
> Jim
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:velocity-user-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


OT Re: How can a list of available templates be obtained?

Posted by Jim Rudnicki <jd...@pacbell.net>.
> > not disallowed by any specification... What Gear calls "large space" can
be

> "Geir"
>
> :)

That's it!  In honor of
his response to almost every post no matter how confused,
his unflappable responses to the most inflammatory posts,
and his general commitment, I propose that us mere mortals spread some
slang:

Anybody does something impressive, you say
"you're a gear, man!"
or
"gear on"

Yep, give it a try.  Spread it around.

Jim



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How can a list of available templates be obtained?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/30/02 4:19 PM, "Attila Szegedi" <sz...@freemail.hu> wrote:

> Given that a class loader can be defined such that it loads dynamically
> generated resources, a getResourcePaths() would eventually have to be able
> to return an infinite collection.... while this is an extreme case, it is
> not disallowed by any specification... What Gear calls "large space" can be
> even "infinite space", or "partially unknown space" (take for instance
> loading resources over HTTP relative to a base URL - you can't enumerate all
> available URLs, at least not in absence of WebDAV).

"Geir"

:)


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting

Age and treachery will always triumph over youth and talent


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How can a list of available templates be obtained?

Posted by Attila Szegedi <sz...@freemail.hu>.
Given that a class loader can be defined such that it loads dynamically
generated resources, a getResourcePaths() would eventually have to be able
to return an infinite collection.... while this is an extreme case, it is
not disallowed by any specification... What Gear calls "large space" can be
even "infinite space", or "partially unknown space" (take for instance
loading resources over HTTP relative to a base URL - you can't enumerate all
available URLs, at least not in absence of WebDAV).

Attila.


----- Original Message -----
From: "Ben Peter" <bp...@zentropypartners.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Thursday, March 28, 2002 10:58 PM
Subject: Re: How can a list of available templates be obtained?


>
> Yes, I feared that, and it makes sense. However, it would be nice if
> java.lang.Classloader had something similar to ServletContext's
> getResourcePaths(String path), which gives you all available resources in
one
> package/directory.
>
> [snip]
>
> > What you might do is extend the JarResourceLoader and use the
Application
> > Attributes (see dev guide) feature to allow your app level code to talk
to
> > the loader.  Then your loader can do fancy things for you and make them
> > available to the app.
>
> Hm, I'll probably not go that far, as it is only a matter of making
deployment
> easier. I'll probably just generate a list of templates at deployment time
and
> read that from a config file.
>
> If I find the time, I'll probably look at whether something of general use
can
> be added to the JarResourceLoader, if that is of any use to others as
well.
>
> Thanks a lot for your answers.
>
> > geir
> --
> Benjamin Peter                                          +49-69-96244395
> Application Engineer                             Moerfelder Landstr. 55
> (zentropy:partners)                            60598 Frankfurt, Germany
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How can a list of available templates be obtained?

Posted by Ben Peter <bp...@zentropypartners.com>.
Geir Magnusson Jr. wrote:
> On 3/28/02 2:13 AM, "Ben Peter" <bp...@zentropypartners.com> wrote:
> 
> 
>>is there a way of obtaining a list of templates that a loader can provide?
> Not really.  The problem is that a loader generally has a large space from
> which it can load.  For example, the FileResourceLoader can access anything
> below any of it's path nodes.  In practice, this is generally small, because
> people usually configure with some limited directory like a /templates
> directory in their webapp tree, but that too can contain multiple
> directories...

[snip]

Yes, I feared that, and it makes sense. However, it would be nice if 
java.lang.Classloader had something similar to ServletContext's 
getResourcePaths(String path), which gives you all available resources in one 
package/directory.

[snip]

> What you might do is extend the JarResourceLoader and use the Application
> Attributes (see dev guide) feature to allow your app level code to talk to
> the loader.  Then your loader can do fancy things for you and make them
> available to the app.

Hm, I'll probably not go that far, as it is only a matter of making deployment 
easier. I'll probably just generate a list of templates at deployment time and 
read that from a config file.

If I find the time, I'll probably look at whether something of general use can 
be added to the JarResourceLoader, if that is of any use to others as well.

Thanks a lot for your answers.

> geir
-- 
Benjamin Peter                                          +49-69-96244395
Application Engineer                             Moerfelder Landstr. 55
(zentropy:partners)                            60598 Frankfurt, Germany


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How can a list of available templates be obtained?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/28/02 2:13 AM, "Ben Peter" <bp...@zentropypartners.com> wrote:

> All,
> 
> is there a way of obtaining a list of templates that a loader can provide?

Not really.  The problem is that a loader generally has a large space from
which it can load.  For example, the FileResourceLoader can access anything
below any of it's path nodes.  In practice, this is generally small, because
people usually configure with some limited directory like a /templates
directory in their webapp tree, but that too can contain multiple
directories...

Of course, you can configure "/" or "C:\" as your template path - so the
list could get quite big.

> 
> I need to make a list of templates in a package/directory available in a drop
> down box, as they are page asset templates.
> 
> With the FileResoureceLoader, this is not a problem, as I can use the same
> directory and read from that. However, I would like to deploy the templates in
> a jar file and use the ClasspathResourceLoader.

This gets even worse - because the ClasspathResourceLoader can access a
whole lot more than your template jar.
 
> Is there a way of finding all templates that reside, say, in
> /com/mycompany/app/templates ?
> 

The JarResourceLoader might be one step forward for you - but I think that
too won't really do it, as there is no 'getAllTemplateNames()' type of
functionality anywhere in the API.

What you might do is extend the JarResourceLoader and use the Application
Attributes (see dev guide) feature to allow your app level code to talk to
the loader.  Then your loader can do fancy things for you and make them
available to the app.

geir
-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
The obvious solutions are challenging


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>