You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Michael Yartsev <an...@gmail.com> on 2008/01/04 06:27:02 UTC

Templates in VelocityLayoutServlet

I'll try to keep this short.

I am creating a website using VLS and part of my template is
/******************************************************
            <div id="content">
                #parse($mainContent)
            </div>
******************************************************/

A small test function I created that is part of the "board" tool
/******************************************************
int c = 0;

public int nexxt() {
    c++;
    return c;
 }
******************************************************/

Here comes the interesting part, at first my pages were like this (test.vm)
/******************************************************
#set($pageTitle = "test page")
#set($mainContent = "test.vm")

$board.nexxt()
******************************************************/

But whenever I load the page, the counter increases by 2. So it is loading
the page twice.

Then, I made two files "test.vm"
/******************************************************
#set($pageTitle = "test page")
#set($mainContent = "test_content.vm")
******************************************************/
and "test_content.vm"
/******************************************************
$board.nexxt()
******************************************************/

Now everything works as expected and the counter goes up by 1.
But, how can I avoid having two pages like this?


On an interesting sidenote if I change the template to
/******************************************************
            <div id="content">
                $mainContent
            </div>
******************************************************/

and test.vm to
/******************************************************
#set($pageTitle = "test page")
#set($mainContent = " #parse('test.vm') ")

$board.nexxt()
******************************************************/

The counter starts going up by 10!!!

Thanks in advance,

-Mike

Re: Missing source StringResourceRepositoryImpl

Posted by Nathan Bubna <nb...@gmail.com>.
Can you provide a link to the nightly builds you're talking about?
I'm not actually aware of any nightly builds.

On Wed, Nov 12, 2008 at 7:00 AM, Steve O'Hara
<so...@pivotal-solutions.co.uk> wrote:
> I'm attempting to debug Velocity from within an IDEA 6 project so
> forgive me if this is some sort of Ant thing happening here.
>
> The source file for StringResourceRepositoryImpl isn't in the latest
> source tree from the nightly builds?
>
> Thanks,
>
> Steve
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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


Missing source StringResourceRepositoryImpl

Posted by Steve O'Hara <so...@pivotal-solutions.co.uk>.
I'm attempting to debug Velocity from within an IDEA 6 project so
forgive me if this is some sort of Ant thing happening here.

The source file for StringResourceRepositoryImpl isn't in the latest
source tree from the nightly builds?

Thanks,

Steve




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


Re: Templates in VelocityLayoutServlet

Posted by Nathan Bubna <nb...@gmail.com>.
On Jan 9, 2008 3:04 PM, Michael Yartsev <an...@gmail.com> wrote:
> > I don't understand what you are trying to accomplish here.  What
> > layout template are you using?  Which template below is your layout
> > and which is your $screen_content?
> >
> > It seems like you are using the layout servlet very strangely, trying
> > to do your own layout system in addition to the built in one.  It's a
> > bit confusing, so i'm not sure how to help you.
>
>
> Using it strangely? How so? (I used this page as a reference:
> http://velocity.apache.org/tools/releases/1.4/view/layoutservlet.html).
>
> According to what is written there, I created my own "Default" template.
>
> > I am creating a website using VLS and part of my template is
> > > /******************************************************
> > >             <div id="content">
> > >                 #parse($mainContent)
> > >             </div>
> > > ******************************************************/

ok, then this is your layout template.  that answers one question.

>
> Then, other ".vm" pages make use of that template.
>

well, the layout servlet will automatically load the "main content"
template, process it and insert it into the context as
$screen_content.  If your layout does not use the $screen_content
reference, then you are definitely using things strangely. :)  All the
example layouts in both the docs and example apps use $screen_content.
 None of them do this #parse( $mainContent ) thing, because none of
them need to.  My guess is that since the layout servlet is
automatically processing test.vm (dealing with your first stage here,
the others are really weird and wrong), then using that same context
(which now has $mainContent = 'test.vm') to process the layout
template, the layout template then pointlessly re-processes test.vm
via the call to #parse( $mainContent ) thus causing the duplicate
processing.  Replace #parse( $mainContent ) with $screen_content and
try again.

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


Re: Templates in VelocityLayoutServlet

Posted by Michael Yartsev <an...@gmail.com>.
> I don't understand what you are trying to accomplish here.  What
> layout template are you using?  Which template below is your layout
> and which is your $screen_content?
>
> It seems like you are using the layout servlet very strangely, trying
> to do your own layout system in addition to the built in one.  It's a
> bit confusing, so i'm not sure how to help you.


Using it strangely? How so? (I used this page as a reference:
http://velocity.apache.org/tools/releases/1.4/view/layoutservlet.html).

According to what is written there, I created my own "Default" template.

> I am creating a website using VLS and part of my template is
> > /******************************************************
> >             <div id="content">
> >                 #parse($mainContent)
> >             </div>
> > ******************************************************/


Then, other ".vm" pages make use of that template.

Re: Templates in VelocityLayoutServlet

Posted by Nathan Bubna <nb...@gmail.com>.
I don't understand what you are trying to accomplish here.  What
layout template are you using?  Which template below is your layout
and which is your $screen_content?

It seems like you are using the layout servlet very strangely, trying
to do your own layout system in addition to the built in one.  It's a
bit confusing, so i'm not sure how to help you.

On Jan 3, 2008 9:27 PM, Michael Yartsev <an...@gmail.com> wrote:
> I'll try to keep this short.
>
> I am creating a website using VLS and part of my template is
> /******************************************************
>             <div id="content">
>                 #parse($mainContent)
>             </div>
> ******************************************************/
>
> A small test function I created that is part of the "board" tool
> /******************************************************
> int c = 0;
>
> public int nexxt() {
>     c++;
>     return c;
>  }
> ******************************************************/
>
> Here comes the interesting part, at first my pages were like this (test.vm)
> /******************************************************
> #set($pageTitle = "test page")
> #set($mainContent = "test.vm")
>
> $board.nexxt()
> ******************************************************/
>
> But whenever I load the page, the counter increases by 2. So it is loading
> the page twice.
>
> Then, I made two files "test.vm"
> /******************************************************
> #set($pageTitle = "test page")
> #set($mainContent = "test_content.vm")
> ******************************************************/
> and "test_content.vm"
> /******************************************************
> $board.nexxt()
> ******************************************************/
>
> Now everything works as expected and the counter goes up by 1.
> But, how can I avoid having two pages like this?
>
>
> On an interesting sidenote if I change the template to
> /******************************************************
>             <div id="content">
>                 $mainContent
>             </div>
> ******************************************************/
>
> and test.vm to
> /******************************************************
> #set($pageTitle = "test page")
> #set($mainContent = " #parse('test.vm') ")
>
> $board.nexxt()
> ******************************************************/
>
> The counter starts going up by 10!!!
>
> Thanks in advance,
>
> -Mike
>

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