You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Marco Pas <ma...@cmg.nl> on 2001/09/27 20:35:35 UTC

Velocity website example...

I was wondering if anyone is willing the share code for a website using
velocity code. To be exact.. where velocity is used as the dynamic or
static HTML generator, this hopefully using jdbc for content retrieval.

- Marco


oracle BC4J with Velocity

Posted by Lee Chun Kiat <ck...@mst.com.my>.
Hi All,

I am very fresh with velocity.

May I know is anyone try to integrate oracle BC4J Framework with velocity?

I face problem with getting the pageContext value..

regards
cklee


Re: Powerd by Velocity

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/30/01 5:33 AM, "Ian Lim" <ma...@yahoo.com.sg> wrote:

> Hi
> 
> Just a suggestion. Maybe we can get to list some of the personal directories
> under the Powered By Velocity section ?

What do you mean 'personal directories'?

Send us the URLs...

geir
 
> At least there are two sites :)
> 
> Regards
> Ian Lim
> 

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



Powerd by Velocity

Posted by Ian Lim <ma...@yahoo.com.sg>.
Hi

Just a suggestion. Maybe we can get to list some of the personal directories
under the Powered By Velocity section ?

At least there are two sites :)

Regards
Ian Lim


Re: Velocity website example...

Posted by Bojan Smojver <bo...@binarix.com>.
Just a few more clarifications:

> 
> - request beans are loaded and initialised every time the correct page
> is hit; for instance, this in beans.properties file:

... and those beans are stored in the current request (so that the
controller can have a go at them).

> - if there is a context-param 'controller' which implements Controller
> (code supplied) interface (and optionally InitProperties interface), it
> will be loaded and initialised and then used as (surprise) MVC
> controller class for the application; its single method (service) is
> called with request, response and Velocity context as parameters; this
> is where some real magic is happening since this guy is also permitted
> to switch the page that is going to be loaded because it returns the new
> template name; you write your own class that does whatever custom
> request processing you have for the app

There is one instance of the controller class per servlet, so you
shouldn't have any concurrence problems (in theory).

Since this whole thing is upside-down, using RequestDispatcher's within
the controller will definitely break things. The idea is that the
controller uses regular Java stuff to do whatever is necessary to
prepare the beans for presentation pass. Since there are no other
servlets within the application, dispatching requests would not have the
desired effect and would cause havoc during template rendering.

Forward functionality of dispatchers can be achieved by changing the
template (by returning a different one from controller's service
method).

Include functionality can be done in Velocity pages themselves based on
values of certain references in the context, prepared by the controller.
But I think this means breaking MVC to a certain extent, not sure
(comments from MVC gurus welcome). For instance:

Java (controller):
--------------------------------------------
if(needMe) ctx.put("includeMe","true");
--------------------------------------------

Velocity:
--------------------------------------------
#if($includeMe)
  #parse("me.vm")
#end
--------------------------------------------

Bojan

Re: Velocity website example...

Posted by Bojan Smojver <bo...@binarix.com>.
Jon Stevens wrote:
> 
> on 9/27/01 7:55 PM, "Bojan Smojver" <bo...@binarix.com> wrote:
> 
> > but if
> > correctly mapped in web.xml, it can handle all Velocity pages (for
> > instance *.vm).
> 
> I need to add this to Turbine soon. It is driving me nuts that we don't have
> that in Turbine land.

Just say the word and a BSD-ish licensed copy is heading your way. It
can at least serve as an example what not to do.

Bojan

Re: Velocity website example...

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/27/01 7:55 PM, "Bojan Smojver" <bo...@binarix.com> wrote:

> but if
> correctly mapped in web.xml, it can handle all Velocity pages (for
> instance *.vm).

I need to add this to Turbine soon. It is driving me nuts that we don't have
that in Turbine land.

-jon


Re: Velocity website example...

Posted by Bojan Smojver <bo...@binarix.com>.
Randy Speh wrote:
> 
> Could someone explain what the PumpServlet is that was
> mentioned in the following message yesterday.

First off, PumpServlet is not part of Velocity distribution, so if it
blows your machine up, please don't blame Velocity developers :-)

PumpServlet is my own entry point for all Velocity applications. It is
just a single servlet (poorly written and probably full of bugs), but if
correctly mapped in web.xml, it can handle all Velocity pages (for
instance *.vm).

The servlet itself is very application centric:

- uses Velocity 1.2 non-singleton (or instance) model to create a
VelocityEngine per application (stored in ServletContext); it will init
the engine from velocity.properties file

- it will load and initialise beans (if the bean implements
InitProperties interface, code supplied with the servlet) of
application, session and request scope that you give it in
beans.properties; properties read from application.properties will be
passed to beans at init time

- application beans are available to all pages in an app (just like JSP)
and are stored in the ServletContext

- session beans are available to the pages within that session (just
like JSP) and are stored in HttpSession

- request beans are loaded and initialised every time the correct page
is hit; for instance, this in beans.properties file:

--------------------------------------------
request.lottery=com.lottery.beans.Win,/lottery/bigwin.vm,/lottery/smallwin.vm
--------------------------------------------

would make sure that every time pages /lottery/bigwin.vm or
/lottery/smallwin.vm are hit, there is a new instance of the lottery
bean

--------------------------------------------
request.lottery=com.lottery.beans.Win
--------------------------------------------

would make lottery bean available to all pages

- there are no page beans (ie. this is not like JSP ;-)

- all beans are stored into Velocity reference $beans (which is a
HashMap) by their names (the part after the scope and before the = sign)
specified in beans.properties; there is also the standard $req and $res
(for Model 1 architectures as well as URL encoding etc.)

- if there is a context-param 'controller' which implements Controller
(code supplied) interface (and optionally InitProperties interface), it
will be loaded and initialised and then used as (surprise) MVC
controller class for the application; its single method (service) is
called with request, response and Velocity context as parameters; this
is where some real magic is happening since this guy is also permitted
to switch the page that is going to be loaded because it returns the new
template name; you write your own class that does whatever custom
request processing you have for the app

- if you don't use MVC (or Model 2), Model 1 is assumed, which means
that .vm pages themselves will be steering the application and calling
business logic bean calls - just in case you find MVC too complicated
for some things; note that if you have the controller, you can still
have some pages on Model 1 by just passing back the same template that
went into the controller (this is getServletPath() from the request)

- .vm page (template) is then merged, but the result will not go to
response until we're sure that everything was cool - therefore the
ByteArrayOutputStream buffer

- if there were problems, servlet will pick up the error page you supply
or failing that its own little piece of XHTML

- this servlet also makes coffee, cleans the house - oh, sorry, no,
wrong servlet ;-)

The thing is currently licensed GPL for one reason alone - it probably
has a lot of bugs, so feedback is welcome. But it can also be licensed
BSD-ish for more freedom in the future.

Bojan

Re: Velocity website example...

Posted by Randy Speh <rw...@yahoo.com>.
Could someone explain what the PumpServlet is that was
mentioned in the following message yesterday.

Thanks,
Randy

--- "Geir Magnusson Jr." <ge...@optonline.net> wrote:
> On 9/27/01 3:26 PM, "Marco Pas" <ma...@cmg.nl>
> wrote:
> 
> > Jon,
> > 
> > i am interested in real-life examples of velocity.
> Example code etc.
> > So not the outside but, the inside...
> 
> The servlet examples in the /examples directory are
> in fact little websites
> unto themselves, although they aren't terribly
> interesting.
> 
> You can start with that, and then start bolting on
> things.
> 
> Also, Bojan Smojver posted this yesterday :
> 
> 
> Apart from being smaller, faster and cheaper
> (hardly), the new version
> features several other improvements:
> 
> - direct support for MVC through Controller
> interface
> - application reloading delegated back to the
> container
> - faster bean initialisation based on InitProperties
> interface
> - page beans dropped
> - request beans can be defined per page(s)
> 
> Available, as usual, with a few auxilary files from
> here:
> 
> ftp://ftp.binarix.com/pub/pump/pump.tar.gz
> 
> Bojan
> 
> 
> 
>  
> > - Marco
> > 
> > On Thu, 27 Sep 2001, Jon Stevens wrote:
> > 
> >> on 9/27/01 11:35 AM, "Marco Pas"
> <ma...@cmg.nl> wrote:
> >> 
> >>> I was wondering if anyone is willing the share
> code for a website using
> >>> velocity code. To be exact.. where velocity is
> used as the dynamic or
> >>> static HTML generator, this hopefully using jdbc
> for content retrieval.
> >>> 
> >>> - Marco
> >> 
> >> What exactly does that get you? All you will see
> is HTML.
> >> 
> >> Anyway, here is a site built with
> Turbine/Velocity/Torque/Fulcrum:
> >> 
> >>     <http://scarab.whichever.com>
> >> 
> >> Here is a couple sites built with Anakia:
> >> 
> >>     <http://www.apache.org/> (around 3 million
> hits/day)
> >>     <http://jakarta.apache.org/>
> >> 
> >> -jon
> >> 
> > 
> 
> -- 
> Geir Magnusson Jr.     geirm@optonline.net
> System and Software Consulting
> "Whoever would overthrow the liberty of a nation
> must begin by subduing the
> freeness of speech." - Benjamin Franklin
> 
> 


__________________________________________________
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.
http://phone.yahoo.com

Re: Velocity website example...

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/27/01 3:26 PM, "Marco Pas" <ma...@cmg.nl> wrote:

> Jon,
> 
> i am interested in real-life examples of velocity. Example code etc.
> So not the outside but, the inside...

The servlet examples in the /examples directory are in fact little websites
unto themselves, although they aren't terribly interesting.

You can start with that, and then start bolting on things.

Also, Bojan Smojver posted this yesterday :


Apart from being smaller, faster and cheaper (hardly), the new version
features several other improvements:

- direct support for MVC through Controller interface
- application reloading delegated back to the container
- faster bean initialisation based on InitProperties interface
- page beans dropped
- request beans can be defined per page(s)

Available, as usual, with a few auxilary files from here:

ftp://ftp.binarix.com/pub/pump/pump.tar.gz

Bojan



 
> - Marco
> 
> On Thu, 27 Sep 2001, Jon Stevens wrote:
> 
>> on 9/27/01 11:35 AM, "Marco Pas" <ma...@cmg.nl> wrote:
>> 
>>> I was wondering if anyone is willing the share code for a website using
>>> velocity code. To be exact.. where velocity is used as the dynamic or
>>> static HTML generator, this hopefully using jdbc for content retrieval.
>>> 
>>> - Marco
>> 
>> What exactly does that get you? All you will see is HTML.
>> 
>> Anyway, here is a site built with Turbine/Velocity/Torque/Fulcrum:
>> 
>>     <http://scarab.whichever.com>
>> 
>> Here is a couple sites built with Anakia:
>> 
>>     <http://www.apache.org/> (around 3 million hits/day)
>>     <http://jakarta.apache.org/>
>> 
>> -jon
>> 
> 

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



Re: Powered by (was: Velocity website example...)

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/27/01 3:05 PM, "Nick Bauman" <ni...@cortexity.com> wrote:

> Jon, Geir,
> 
> You could add www.webhelp.com, my day job to
> 
> http://jakarta.apache.org/velocity/powered.html

Patches to the .xml file are welcome. :-)

-jon


Re: Powered by (was: Velocity website example...)

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/27/01 6:05 PM, "Nick Bauman" <ni...@cortexity.com> wrote:

> Jon, Geir,
> 
> You could add www.webhelp.com, my day job to
> 
> http://jakarta.apache.org/velocity/powered.html
> 
> Webhelp is a company that provides distributed call center integration
> software and services for web and wireless technologies.
> 
> I incorporated Velocity with our ETranscript component, so that events
> generated in a conference are rendered as MIME email and XML using Velocity
> templates.
> 
> I'm working on another project outside webhelp that is using Velocity as
> well. It'll be ready soon.
> 
> What an amazing tool Velocity is.

I am putting you in 'powered by' under sites, noting that it's in your
'Etranscript' component (whatever that is.)

Would it be more appropos to put you in the 'products' area?

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



Powered by (was: Velocity website example...)

Posted by Nick Bauman <ni...@cortexity.com>.
Jon, Geir,

You could add www.webhelp.com, my day job to 

http://jakarta.apache.org/velocity/powered.html

Webhelp is a company that provides distributed call center integration
software and services for web and wireless technologies.

I incorporated Velocity with our ETranscript component, so that events
generated in a conference are rendered as MIME email and XML using Velocity
templates.

I'm working on another project outside webhelp that is using Velocity as
well. It'll be ready soon.

What an amazing tool Velocity is. 

> 
> What is wrong with:
> 
> <http://jakarta.apache.org/velocity/powered.html>
> 
> -jon


-- 
Nick Bauman | Minneapolis, MN 55412
M: (612) 232-7120 |H: (612) 522-0165


Re: Velocity website example...

Posted by Marco Pas <ma...@cmg.nl>.
Nothing wrong with, it is just great to say the least!
But it tells nothing how these sites are implemented.
Code examples that is what i am looking for.. but you pointed me already
into a number of good directions (pump)

Txs
- Marco

On Thu, 27 Sep 2001, Jon Stevens wrote:

> on 9/27/01 12:26 PM, "Marco Pas" <ma...@cmg.nl> wrote:
>
> > Jon,
> >
> > i am interested in real-life examples of velocity. Example code etc.
> > So not the outside but, the inside...
> >
> > - Marco
>
> What is wrong with:
>
> <http://jakarta.apache.org/velocity/powered.html>
>
> -jon
>


Re: Velocity website example...

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/27/01 12:26 PM, "Marco Pas" <ma...@cmg.nl> wrote:

> Jon,
> 
> i am interested in real-life examples of velocity. Example code etc.
> So not the outside but, the inside...
> 
> - Marco

What is wrong with:

<http://jakarta.apache.org/velocity/powered.html>

-jon


Re: Velocity website example...

Posted by Marco Pas <ma...@cmg.nl>.
Jon,

i am interested in real-life examples of velocity. Example code etc.
So not the outside but, the inside...

- Marco

On Thu, 27 Sep 2001, Jon Stevens wrote:

> on 9/27/01 11:35 AM, "Marco Pas" <ma...@cmg.nl> wrote:
>
> > I was wondering if anyone is willing the share code for a website using
> > velocity code. To be exact.. where velocity is used as the dynamic or
> > static HTML generator, this hopefully using jdbc for content retrieval.
> >
> > - Marco
>
> What exactly does that get you? All you will see is HTML.
>
> Anyway, here is a site built with Turbine/Velocity/Torque/Fulcrum:
>
>     <http://scarab.whichever.com>
>
> Here is a couple sites built with Anakia:
>
>     <http://www.apache.org/> (around 3 million hits/day)
>     <http://jakarta.apache.org/>
>
> -jon
>


Re: Velocity website example...

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/27/01 11:35 AM, "Marco Pas" <ma...@cmg.nl> wrote:

> I was wondering if anyone is willing the share code for a website using
> velocity code. To be exact.. where velocity is used as the dynamic or
> static HTML generator, this hopefully using jdbc for content retrieval.
> 
> - Marco

What exactly does that get you? All you will see is HTML.

Anyway, here is a site built with Turbine/Velocity/Torque/Fulcrum:

    <http://scarab.whichever.com>

Here is a couple sites built with Anakia:

    <http://www.apache.org/> (around 3 million hits/day)
    <http://jakarta.apache.org/>

-jon