velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Yartsev" <ani...@gmail.com>
Subject Templates in VelocityLayoutServlet
Date Fri, 04 Jan 2008 05:27:02 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message