You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Patrick Olivier <ti...@free.fr> on 2007/08/07 09:56:17 UTC

VelocityViewServlet and HTML form

Hi,

I'm trying to modify the simple example provided with velocity tools 1.3 (
simple.war ). What i want to do is to add an html form in the index.vm template
:

...
<form method="post" action="index.vm">
<input type="text" name="message" value="$!toytool.message">
<input type="submit" value="Send">
</form>
...

When pressing down the 'Send' button, i'm expecting an access to the setter of
message in ToyTool ( the getter works well ), but nothing happens !
What's wrong in the code above ?
do i forget something ( or misunderstand something ? )

Thx for your help.
-Patrick


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


Re: VelocityViewServlet and HTML form

Posted by Malcolm Edgar <ma...@gmail.com>.
Hi Patrick,

If you are doing a lot of form work, you may find the Click Framework
useful. Its a web framework which uses Velocity for rendering, and has
extensive form support.

regards Malcolm Edgar
http://click.sourceforge.net

On 8/7/07, Claude Brisson <cl...@renegat.net> wrote:
> Le mardi 07 août 2007 à 09:56 +0200, Patrick Olivier a écrit :
> > Hi,
> >
> > I'm trying to modify the simple example provided with velocity tools 1.3 (
> > simple.war ). What i want to do is to add an html form in the index.vm template
> > :
> >
> > ...
> > <form method="post" action="index.vm">
> > <input type="text" name="message" value="$!toytool.message">
> > <input type="submit" value="Send">
> > </form>
> > ...
> >
> > When pressing down the 'Send' button, i'm expecting an access to the setter of
> > message in ToyTool ( the getter works well ), but nothing happens !
> > What's wrong in the code above ?
> > do i forget something ( or misunderstand something ? )
>
> Wrong expectation... Velocity doesn't know what a form is. The form is
> submitted on the client side, Velocity is on the server side.
>
> When you press the 'Send' button, the server will receive a request on
> index.vm with the 'message' HTTP query attribute set to your value. At
> this point, you can use the ParameterParser tool to grab the value :
>
> #if($param.message) #set($toytool.message = $param.message) #end
>
>
>   Claude
>
> > Thx for your help.
> > -Patrick
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>

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


Re: VelocityViewServlet and HTML form

Posted by Claude Brisson <cl...@renegat.net>.
Le mardi 07 août 2007 à 09:56 +0200, Patrick Olivier a écrit :
> Hi,
> 
> I'm trying to modify the simple example provided with velocity tools 1.3 (
> simple.war ). What i want to do is to add an html form in the index.vm template
> :
> 
> ...
> <form method="post" action="index.vm">
> <input type="text" name="message" value="$!toytool.message">
> <input type="submit" value="Send">
> </form>
> ...
> 
> When pressing down the 'Send' button, i'm expecting an access to the setter of
> message in ToyTool ( the getter works well ), but nothing happens !
> What's wrong in the code above ?
> do i forget something ( or misunderstand something ? )

Wrong expectation... Velocity doesn't know what a form is. The form is
submitted on the client side, Velocity is on the server side.

When you press the 'Send' button, the server will receive a request on
index.vm with the 'message' HTTP query attribute set to your value. At
this point, you can use the ParameterParser tool to grab the value :

#if($param.message) #set($toytool.message = $param.message) #end


  Claude

> Thx for your help.
> -Patrick
> 
> 
> ---------------------------------------------------------------------
> 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