You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Xavier Ottolini <xa...@qualipse.fr> on 2003/01/20 09:41:42 UTC

difference between ParameterParser.add and context.put

Hi !

I just ask myselft about some syntax expresson seen in TDK.

What is the difference between
data.getParameters().add("inputname", value);
and
context.put("inputname", value); ?

(data is a RunData instance and context a Context instance).

In which case should we use Parameter.add()

Regards

Xavier


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: difference between ParameterParser.add and context.put

Posted by Derick Fernando <de...@xenocex.com>.
Hi,

Parameters are usually encoded into the URL, for example
Display.vm?show=thisproduct.
context.put however is for feeding data into velocity template.

Short example:

If you have a single screen that displays products, such as Display.vm, it
could accept parameters like:

Display.vm?show=thisproduct. Which would be in your template like
$link.setPage("Display.vm").addQueryData("show","thisproduct")

Turbine also does this using addPathInfo which you are better off using
because it encodes Parameters like:
Display.vm/show/thisproduct. This has the advantage that search engine
crawlers follow these links (as far as I know).

The query parameter has just told us we want to display "thisproduct". We
can find this product in the database or where ever and add it into the
context (which accepts objects).

So if we did context.put("prod", Product);

Assuming Product has the get methods, we could use it like so in a template:

$prod.name
$prod.description

and so on.

So parameters are best suited for passing information between pages or
useful when you want to invoke something on that page via a URL.

Hope that made sense.

Derick


----- Original Message -----
From: "Xavier Ottolini" <xa...@qualipse.fr>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Monday, January 20, 2003 12:41 AM
Subject: difference between ParameterParser.add and context.put


> Hi !
>
> I just ask myselft about some syntax expresson seen in TDK.
>
> What is the difference between
> data.getParameters().add("inputname", value);
> and
> context.put("inputname", value); ?
>
> (data is a RunData instance and context a Context instance).
>
> In which case should we use Parameter.add()
>
> Regards
>
> Xavier
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>