You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Andrew Berman <at...@gmail.com> on 2009/07/22 00:55:50 UTC

Loading Velocity Templates

Hello,

I currently use Velocity templates within my Wicket 1.3 application, and I
have been using VelocityPanel.forTemplateResource to locate my resources
passing it the actual file URL of the velocity template.  However, I now
have a need to find the velocity templates in the same way the HTML files
are found.  In other words, I need to find it based on the default algorithm
of:

1. [sourcePath]/name[style][locale].[extension]
2. [sourcePath]/name[locale].[extension]
3. [sourcePath]/name[style].[extension]
4. [sourcePath]/name.[extension]
5. [classPath]/name[style][locale].[extension]
6. [classPath]/name[locale].[extension]
7. [classPath]/name[style].[extension]
8. [classPath]/name.[extension]

Each velocity template is named the same as the Page or Panel it is used
with.  How would I go about loading the velocity template to accomplish
this?

Thanks for your help,

Andrew

Re: Loading Velocity Templates

Posted by Andrew Berman <at...@gmail.com>.
I was not able to get it to work with ResourceStreamLocator.  Whatever I
passed in for the path yielded a null stream.  The iterator does work
though, so I'm just going to loop through it and check for null.

Thanks again Igor!

On Wed, Jul 22, 2009 at 11:09 AM, Andrew Berman <at...@gmail.com> wrote:

> It looks like ResourceStreamLocator has the logic I'm looking for.  Let me
> give it a shot and I'll let you know if it works.
>
> Thanks for your help!
>
>
> On Wed, Jul 22, 2009 at 11:05 AM, Andrew Berman <at...@gmail.com>wrote:
>
>> OK, so the iterator does return all combinations, so I guess I have to
>> loop through them and check for their existence.  I don't suppose Wicket has
>> anything to do that already since it must be doing something like this with
>> the HTML?
>>
>>
>> On Tue, Jul 21, 2009 at 5:06 PM, Igor Vaynberg <ig...@gmail.com>wrote:
>>
>>> On Tue, Jul 21, 2009 at 4:17 PM, Andrew Berman<at...@gmail.com>
>>> wrote:
>>> > What exactly do I pass into the path part?  Do I pass in a full
>>> directory
>>> > structure or just the name of the file?
>>>
>>> it doesnt matter - whatever you pass in is whatever you will get back
>>> - it is basically a prefix.
>>>
>>> i havent tried to use this myself, but looking from the source code in
>>> wicket it looks like it should work.
>>>
>>> -igor
>>>
>>>
>>>
>>> > I've tried this before and I always
>>> > get a null.
>>> >
>>> > Thanks Igor
>>> >
>>> > On Tue, Jul 21, 2009 at 4:05 PM, Igor Vaynberg <
>>> igor.vaynberg@gmail.com>wrote:
>>> >
>>> >> see if ResourceNameIterator helps
>>> >>
>>> >> -igor
>>> >>
>>> >> On Tue, Jul 21, 2009 at 3:55 PM, Andrew Berman<at...@gmail.com>
>>> wrote:
>>> >> > Hello,
>>> >> >
>>> >> > I currently use Velocity templates within my Wicket 1.3 application,
>>> and
>>> >> I
>>> >> > have been using VelocityPanel.forTemplateResource to locate my
>>> resources
>>> >> > passing it the actual file URL of the velocity template.  However, I
>>> now
>>> >> > have a need to find the velocity templates in the same way the HTML
>>> files
>>> >> > are found.  In other words, I need to find it based on the default
>>> >> algorithm
>>> >> > of:
>>> >> >
>>> >> > 1. [sourcePath]/name[style][locale].[extension]
>>> >> > 2. [sourcePath]/name[locale].[extension]
>>> >> > 3. [sourcePath]/name[style].[extension]
>>> >> > 4. [sourcePath]/name.[extension]
>>> >> > 5. [classPath]/name[style][locale].[extension]
>>> >> > 6. [classPath]/name[locale].[extension]
>>> >> > 7. [classPath]/name[style].[extension]
>>> >> > 8. [classPath]/name.[extension]
>>> >> >
>>> >> > Each velocity template is named the same as the Page or Panel it is
>>> used
>>> >> > with.  How would I go about loading the velocity template to
>>> accomplish
>>> >> > this?
>>> >> >
>>> >> > Thanks for your help,
>>> >> >
>>> >> > Andrew
>>> >> >
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> >> For additional commands, e-mail: users-help@wicket.apache.org
>>> >>
>>> >>
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>

Re: Loading Velocity Templates

Posted by Andrew Berman <at...@gmail.com>.
It looks like ResourceStreamLocator has the logic I'm looking for.  Let me
give it a shot and I'll let you know if it works.

Thanks for your help!

On Wed, Jul 22, 2009 at 11:05 AM, Andrew Berman <at...@gmail.com> wrote:

> OK, so the iterator does return all combinations, so I guess I have to loop
> through them and check for their existence.  I don't suppose Wicket has
> anything to do that already since it must be doing something like this with
> the HTML?
>
>
> On Tue, Jul 21, 2009 at 5:06 PM, Igor Vaynberg <ig...@gmail.com>wrote:
>
>> On Tue, Jul 21, 2009 at 4:17 PM, Andrew Berman<at...@gmail.com> wrote:
>> > What exactly do I pass into the path part?  Do I pass in a full
>> directory
>> > structure or just the name of the file?
>>
>> it doesnt matter - whatever you pass in is whatever you will get back
>> - it is basically a prefix.
>>
>> i havent tried to use this myself, but looking from the source code in
>> wicket it looks like it should work.
>>
>> -igor
>>
>>
>>
>> > I've tried this before and I always
>> > get a null.
>> >
>> > Thanks Igor
>> >
>> > On Tue, Jul 21, 2009 at 4:05 PM, Igor Vaynberg <igor.vaynberg@gmail.com
>> >wrote:
>> >
>> >> see if ResourceNameIterator helps
>> >>
>> >> -igor
>> >>
>> >> On Tue, Jul 21, 2009 at 3:55 PM, Andrew Berman<at...@gmail.com>
>> wrote:
>> >> > Hello,
>> >> >
>> >> > I currently use Velocity templates within my Wicket 1.3 application,
>> and
>> >> I
>> >> > have been using VelocityPanel.forTemplateResource to locate my
>> resources
>> >> > passing it the actual file URL of the velocity template.  However, I
>> now
>> >> > have a need to find the velocity templates in the same way the HTML
>> files
>> >> > are found.  In other words, I need to find it based on the default
>> >> algorithm
>> >> > of:
>> >> >
>> >> > 1. [sourcePath]/name[style][locale].[extension]
>> >> > 2. [sourcePath]/name[locale].[extension]
>> >> > 3. [sourcePath]/name[style].[extension]
>> >> > 4. [sourcePath]/name.[extension]
>> >> > 5. [classPath]/name[style][locale].[extension]
>> >> > 6. [classPath]/name[locale].[extension]
>> >> > 7. [classPath]/name[style].[extension]
>> >> > 8. [classPath]/name.[extension]
>> >> >
>> >> > Each velocity template is named the same as the Page or Panel it is
>> used
>> >> > with.  How would I go about loading the velocity template to
>> accomplish
>> >> > this?
>> >> >
>> >> > Thanks for your help,
>> >> >
>> >> > Andrew
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: Loading Velocity Templates

Posted by Andrew Berman <at...@gmail.com>.
OK, so the iterator does return all combinations, so I guess I have to loop
through them and check for their existence.  I don't suppose Wicket has
anything to do that already since it must be doing something like this with
the HTML?

On Tue, Jul 21, 2009 at 5:06 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> On Tue, Jul 21, 2009 at 4:17 PM, Andrew Berman<at...@gmail.com> wrote:
> > What exactly do I pass into the path part?  Do I pass in a full directory
> > structure or just the name of the file?
>
> it doesnt matter - whatever you pass in is whatever you will get back
> - it is basically a prefix.
>
> i havent tried to use this myself, but looking from the source code in
> wicket it looks like it should work.
>
> -igor
>
>
>
> > I've tried this before and I always
> > get a null.
> >
> > Thanks Igor
> >
> > On Tue, Jul 21, 2009 at 4:05 PM, Igor Vaynberg <igor.vaynberg@gmail.com
> >wrote:
> >
> >> see if ResourceNameIterator helps
> >>
> >> -igor
> >>
> >> On Tue, Jul 21, 2009 at 3:55 PM, Andrew Berman<at...@gmail.com>
> wrote:
> >> > Hello,
> >> >
> >> > I currently use Velocity templates within my Wicket 1.3 application,
> and
> >> I
> >> > have been using VelocityPanel.forTemplateResource to locate my
> resources
> >> > passing it the actual file URL of the velocity template.  However, I
> now
> >> > have a need to find the velocity templates in the same way the HTML
> files
> >> > are found.  In other words, I need to find it based on the default
> >> algorithm
> >> > of:
> >> >
> >> > 1. [sourcePath]/name[style][locale].[extension]
> >> > 2. [sourcePath]/name[locale].[extension]
> >> > 3. [sourcePath]/name[style].[extension]
> >> > 4. [sourcePath]/name.[extension]
> >> > 5. [classPath]/name[style][locale].[extension]
> >> > 6. [classPath]/name[locale].[extension]
> >> > 7. [classPath]/name[style].[extension]
> >> > 8. [classPath]/name.[extension]
> >> >
> >> > Each velocity template is named the same as the Page or Panel it is
> used
> >> > with.  How would I go about loading the velocity template to
> accomplish
> >> > this?
> >> >
> >> > Thanks for your help,
> >> >
> >> > Andrew
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Loading Velocity Templates

Posted by Igor Vaynberg <ig...@gmail.com>.
On Tue, Jul 21, 2009 at 4:17 PM, Andrew Berman<at...@gmail.com> wrote:
> What exactly do I pass into the path part?  Do I pass in a full directory
> structure or just the name of the file?

it doesnt matter - whatever you pass in is whatever you will get back
- it is basically a prefix.

i havent tried to use this myself, but looking from the source code in
wicket it looks like it should work.

-igor



> I've tried this before and I always
> get a null.
>
> Thanks Igor
>
> On Tue, Jul 21, 2009 at 4:05 PM, Igor Vaynberg <ig...@gmail.com>wrote:
>
>> see if ResourceNameIterator helps
>>
>> -igor
>>
>> On Tue, Jul 21, 2009 at 3:55 PM, Andrew Berman<at...@gmail.com> wrote:
>> > Hello,
>> >
>> > I currently use Velocity templates within my Wicket 1.3 application, and
>> I
>> > have been using VelocityPanel.forTemplateResource to locate my resources
>> > passing it the actual file URL of the velocity template.  However, I now
>> > have a need to find the velocity templates in the same way the HTML files
>> > are found.  In other words, I need to find it based on the default
>> algorithm
>> > of:
>> >
>> > 1. [sourcePath]/name[style][locale].[extension]
>> > 2. [sourcePath]/name[locale].[extension]
>> > 3. [sourcePath]/name[style].[extension]
>> > 4. [sourcePath]/name.[extension]
>> > 5. [classPath]/name[style][locale].[extension]
>> > 6. [classPath]/name[locale].[extension]
>> > 7. [classPath]/name[style].[extension]
>> > 8. [classPath]/name.[extension]
>> >
>> > Each velocity template is named the same as the Page or Panel it is used
>> > with.  How would I go about loading the velocity template to accomplish
>> > this?
>> >
>> > Thanks for your help,
>> >
>> > Andrew
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

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


Re: Loading Velocity Templates

Posted by Andrew Berman <at...@gmail.com>.
What exactly do I pass into the path part?  Do I pass in a full directory
structure or just the name of the file?  I've tried this before and I always
get a null.

Thanks Igor

On Tue, Jul 21, 2009 at 4:05 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> see if ResourceNameIterator helps
>
> -igor
>
> On Tue, Jul 21, 2009 at 3:55 PM, Andrew Berman<at...@gmail.com> wrote:
> > Hello,
> >
> > I currently use Velocity templates within my Wicket 1.3 application, and
> I
> > have been using VelocityPanel.forTemplateResource to locate my resources
> > passing it the actual file URL of the velocity template.  However, I now
> > have a need to find the velocity templates in the same way the HTML files
> > are found.  In other words, I need to find it based on the default
> algorithm
> > of:
> >
> > 1. [sourcePath]/name[style][locale].[extension]
> > 2. [sourcePath]/name[locale].[extension]
> > 3. [sourcePath]/name[style].[extension]
> > 4. [sourcePath]/name.[extension]
> > 5. [classPath]/name[style][locale].[extension]
> > 6. [classPath]/name[locale].[extension]
> > 7. [classPath]/name[style].[extension]
> > 8. [classPath]/name.[extension]
> >
> > Each velocity template is named the same as the Page or Panel it is used
> > with.  How would I go about loading the velocity template to accomplish
> > this?
> >
> > Thanks for your help,
> >
> > Andrew
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Loading Velocity Templates

Posted by Igor Vaynberg <ig...@gmail.com>.
see if ResourceNameIterator helps

-igor

On Tue, Jul 21, 2009 at 3:55 PM, Andrew Berman<at...@gmail.com> wrote:
> Hello,
>
> I currently use Velocity templates within my Wicket 1.3 application, and I
> have been using VelocityPanel.forTemplateResource to locate my resources
> passing it the actual file URL of the velocity template.  However, I now
> have a need to find the velocity templates in the same way the HTML files
> are found.  In other words, I need to find it based on the default algorithm
> of:
>
> 1. [sourcePath]/name[style][locale].[extension]
> 2. [sourcePath]/name[locale].[extension]
> 3. [sourcePath]/name[style].[extension]
> 4. [sourcePath]/name.[extension]
> 5. [classPath]/name[style][locale].[extension]
> 6. [classPath]/name[locale].[extension]
> 7. [classPath]/name[style].[extension]
> 8. [classPath]/name.[extension]
>
> Each velocity template is named the same as the Page or Panel it is used
> with.  How would I go about loading the velocity template to accomplish
> this?
>
> Thanks for your help,
>
> Andrew
>

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