You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Ken <ke...@pacific.net> on 2002/03/23 01:05:38 UTC

put parameter values back into context?

Is this the best way to get all the parameters from a form and
put them back into the context, or is there some simpler way
that I've overlooked?

Enumeration par_names = request.getParameterNames();
 while(par_names.hasMoreElements()){
   String s1 = par_names.nextElement().toString();
   ctx.put(s1,request.getParameter(s1));
 }

Thanks,
Ken


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


Re: put parameter values back into context?

Posted by Ken Anderson <ka...@pacific.net>.
I guess I don't see why you'd want to do that, but communication is an
imperfect tool, alas....
Back to hacking with velocity!
Ken


Daniel Dekany wrote:
> 
> > What kind of encoding are you referring to?
> 
> Replacing quotion marks with &quot; etc...
> 
> > Ken
> >
> >
> > Daniel Dekany wrote:
> >
> > >----- Original Message -----
> > >From: "Ken Anderson" <ka...@pacific.net>
> > >Sent: Tuesday, March 26, 2002 1:55 AM
> > >
> > >Just would like to notice something offtopic:
> > >Perhaps I have overlooked something but when I see this:
> > >  value="!$request.Parameter.Name"
> > >then I think that you forget to encode the value. I know I'm such a fussy
> > >man. :)
> [snip]
> 
> --
> 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>


Re: put parameter values back into context?

Posted by Daniel Dekany <dd...@freemail.hu>.
On Tuesday, March 26, 2002 4:01 AM "Ken Anderson" <ka...@pacific.net> wrote:

> Note that the '$' comes before the '!' in $!name.

Ops. True... however I just copy-pasted it from this thread.

> What kind of encoding are you referring to?

Replacing quotion marks with &quot; etc...

> Ken
>
>
> Daniel Dekany wrote:
>
> >----- Original Message -----
> >From: "Ken Anderson" <ka...@pacific.net>
> >Sent: Tuesday, March 26, 2002 1:55 AM
> >
> >Just would like to notice something offtopic:
> >Perhaps I have overlooked something but when I see this:
> >  value="!$request.Parameter.Name"
> >then I think that you forget to encode the value. I know I'm such a fussy
> >man. :)
[snip]



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


Re: put parameter values back into context?

Posted by Ken Anderson <ka...@pacific.net>.
Note that the '$' comes before the '!' in $!name.
What kind of encoding are you referring to?
Ken


Daniel Dekany wrote:

>----- Original Message -----
>From: "Ken Anderson" <ka...@pacific.net>
>Sent: Tuesday, March 26, 2002 1:55 AM
>
>Just would like to notice something offtopic:
>Perhaps I have overlooked something but when I see this:
>  value="!$request.Parameter.Name"
>then I think that you forget to encode the value. I know I'm such a fussy
>man. :)
>
>>Yes, Thanks. The silent notation $!name works good with form data.
>>Much better than this (which is what I did before looking at the users
>>guide..)
>>:-)
>>
>>#if ($name)
>><input type="text" name="username" value="$name">
>>#else
>><input type="text" name="username" value="">
>>#end
>>
>>Ken
>>
>>
>>"Charles N. Harvey III" wrote:
>>
>>>Use the silent notation in the form fields.
>>>
>>>Do this in your servlet:
>>>
>>>>>>context.put( "request", request );
>>>>>>
>>>>>>$request.Parameter.Name
>>>>>>$request.Parameter.Password
>>>>>>$request.Parameter.FavoriteCheese
>>>>>>
>>>Then, in your html page use the silent notation so that the first time
>>>the page loads you will see blanks, but if the page loads again you will
>>>see values filled in.
>>>
>>><form>
>>><input type="text" name="username" value="!$request.Parameter.Name" />
>>><input type="submit" value="Submit" />
>>></form>
>>>
>[snip]
>
>
>--
>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>


Re: put parameter values back into context?

Posted by Daniel Dekany <dd...@freemail.hu>.
----- Original Message -----
From: "Ken Anderson" <ka...@pacific.net>
Sent: Tuesday, March 26, 2002 1:55 AM

Just would like to notice something offtopic:
Perhaps I have overlooked something but when I see this:
  value="!$request.Parameter.Name"
then I think that you forget to encode the value. I know I'm such a fussy
man. :)

> Yes, Thanks. The silent notation $!name works good with form data.
> Much better than this (which is what I did before looking at the users
> guide..)
> :-)
>
> #if ($name)
> <input type="text" name="username" value="$name">
> #else
> <input type="text" name="username" value="">
> #end
>
> Ken
>
>
> "Charles N. Harvey III" wrote:
> >
> > Use the silent notation in the form fields.
> >
> > Do this in your servlet:
> > > >> context.put( "request", request );
> > > >>
> > > >> $request.Parameter.Name
> > > >> $request.Parameter.Password
> > > >> $request.Parameter.FavoriteCheese
> >
> > Then, in your html page use the silent notation so that the first time
> > the page loads you will see blanks, but if the page loads again you will
> > see values filled in.
> >
> > <form>
> > <input type="text" name="username" value="!$request.Parameter.Name" />
> > <input type="submit" value="Submit" />
> > </form>
[snip]


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


Re: put parameter values back into context?

Posted by Ken Anderson <ka...@pacific.net>.
Yes, Thanks. The silent notation $!name works good with form data.
Much better than this (which is what I did before looking at the users
guide..)
:-)

#if ($name)
<input type="text" name="username" value="$name">
#else
<input type="text" name="username" value="">
#end

Ken


"Charles N. Harvey III" wrote:
> 
> Use the silent notation in the form fields.
> 
> Do this in your servlet:
> > >> context.put( "request", request );
> > >>
> > >> $request.Parameter.Name
> > >> $request.Parameter.Password
> > >> $request.Parameter.FavoriteCheese
> 
> Then, in your html page use the silent notation so that the first time
> the page loads you will see blanks, but if the page loads again you will
> see values filled in.
> 
> <form>
> <input type="text" name="username" value="!$request.Parameter.Name" />
> <input type="submit" value="Submit" />
> </form>
> 
> Try that.
> 
> Charlie
> 
> > -----Original Message-----
> > From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> > Sent: Saturday, March 23, 2002 12:57 PM
> > To: velocity-user@jakarta.apache.org
> > Subject: Re: put parameter values back into context?
> >
> >
> > On 3/23/02 12:48 PM, "Ken Anderson" <ka...@pacific.net> wrote:
> >
> > > Thanks, but because the context is the same template (form) again,
> > > after an error condition is found (bad password or failed form
> > validation),
> > > I'd like to send back the same set of simple variables; $username,
> > > $password, etc,
> > > so that they can populate the input fields again.
> > > I also like to keep it as simple as possible for the web developer.
> > > I give them a short list of variables, and they don't have to think
> > > about properties or
> > > methods unless it really makes sense to expose those things at the
> > > template level.
> >
> > Yes - I agree if you are saying that you want the values to be in the
> > context the same way each time - the yes, you want to take care of that
> > before rendering the template...
> >
> > > Ken
> > >
> > >
> > > bob mcwhirter wrote:
> > >
> > >> context.put( "request", request );
> > >>
> > >> $request.Parameter.Name
> > >> $request.Parameter.Password
> > >> $request.Parameter.FavoriteCheese
> > >>
> > >> -bob
> > >>
> > >>
> > >> On Fri, 22 Mar 2002, Ken wrote:
> > >>
> > >>> Is this the best way to get all the parameters from a form and
> > >>> put them back into the context, or is there some simpler way
> > >>> that I've overlooked?
> > >>>
> > >>> Enumeration par_names = request.getParameterNames();
> > >>> while(par_names.hasMoreElements()){
> > >>>   String s1 = par_names.nextElement().toString();
> > >>>   ctx.put(s1,request.getParameter(s1));
> > >>> }
> > >>>
> > >>> Thanks,
> > >>> Ken
> > >>>
> > >>>
> > >>> --
> > >>> 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>
> > >>
> > >>
> > >>
> > >
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > >
> >
> > --
> > Geir Magnusson Jr.                                     geirm@optonline.net
> > System and Software Consulting
> >
> > Age and treachery will always triumph over youth and talent
> >
> >
> > --
> > 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>

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


RE: put parameter values back into context?

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
Use the silent notation in the form fields.

Do this in your servlet:
> >> context.put( "request", request );
> >>
> >> $request.Parameter.Name
> >> $request.Parameter.Password
> >> $request.Parameter.FavoriteCheese

Then, in your html page use the silent notation so that the first time
the page loads you will see blanks, but if the page loads again you will
see values filled in.

<form>
<input type="text" name="username" value="!$request.Parameter.Name" />
<input type="submit" value="Submit" />
</form>


Try that.

Charlie

> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Saturday, March 23, 2002 12:57 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: put parameter values back into context?
>
>
> On 3/23/02 12:48 PM, "Ken Anderson" <ka...@pacific.net> wrote:
>
> > Thanks, but because the context is the same template (form) again,
> > after an error condition is found (bad password or failed form
> validation),
> > I'd like to send back the same set of simple variables; $username,
> > $password, etc,
> > so that they can populate the input fields again.
> > I also like to keep it as simple as possible for the web developer.
> > I give them a short list of variables, and they don't have to think
> > about properties or
> > methods unless it really makes sense to expose those things at the
> > template level.
>
> Yes - I agree if you are saying that you want the values to be in the
> context the same way each time - the yes, you want to take care of that
> before rendering the template...
>
> > Ken
> >
> >
> > bob mcwhirter wrote:
> >
> >> context.put( "request", request );
> >>
> >> $request.Parameter.Name
> >> $request.Parameter.Password
> >> $request.Parameter.FavoriteCheese
> >>
> >> -bob
> >>
> >>
> >> On Fri, 22 Mar 2002, Ken wrote:
> >>
> >>> Is this the best way to get all the parameters from a form and
> >>> put them back into the context, or is there some simpler way
> >>> that I've overlooked?
> >>>
> >>> Enumeration par_names = request.getParameterNames();
> >>> while(par_names.hasMoreElements()){
> >>>   String s1 = par_names.nextElement().toString();
> >>>   ctx.put(s1,request.getParameter(s1));
> >>> }
> >>>
> >>> Thanks,
> >>> Ken
> >>>
> >>>
> >>> --
> >>> 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>
> >>
> >>
> >>
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
>
> --
> Geir Magnusson Jr.                                     geirm@optonline.net
> System and Software Consulting
>
> Age and treachery will always triumph over youth and talent
>
>
> --
> 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>


Re: put parameter values back into context?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/23/02 12:48 PM, "Ken Anderson" <ka...@pacific.net> wrote:

> Thanks, but because the context is the same template (form) again,
> after an error condition is found (bad password or failed form validation),
> I'd like to send back the same set of simple variables; $username,
> $password, etc,
> so that they can populate the input fields again.
> I also like to keep it as simple as possible for the web developer.
> I give them a short list of variables, and they don't have to think
> about properties or
> methods unless it really makes sense to expose those things at the
> template level.

Yes - I agree if you are saying that you want the values to be in the
context the same way each time - the yes, you want to take care of that
before rendering the template...

> Ken
> 
> 
> bob mcwhirter wrote:
> 
>> context.put( "request", request );
>> 
>> $request.Parameter.Name
>> $request.Parameter.Password
>> $request.Parameter.FavoriteCheese
>> 
>> -bob
>> 
>> 
>> On Fri, 22 Mar 2002, Ken wrote:
>> 
>>> Is this the best way to get all the parameters from a form and
>>> put them back into the context, or is there some simpler way
>>> that I've overlooked?
>>> 
>>> Enumeration par_names = request.getParameterNames();
>>> while(par_names.hasMoreElements()){
>>>   String s1 = par_names.nextElement().toString();
>>>   ctx.put(s1,request.getParameter(s1));
>>> }
>>> 
>>> Thanks,
>>> Ken
>>> 
>>> 
>>> --
>>> 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>
>> 
>> 
>> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting

Age and treachery will always triumph over youth and talent


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


Re: put parameter values back into context?

Posted by Ken Anderson <ka...@pacific.net>.
Thanks, but because the context is the same template (form) again,
after an error condition is found (bad password or failed form validation),
I'd like to send back the same set of simple variables; $username, 
$password, etc,
so that they can populate the input fields again.
I also like to keep it as simple as possible for the web developer.
I give them a short list of variables, and they don't have to think 
about properties or
methods unless it really makes sense to expose those things at the 
template level.
Ken


bob mcwhirter wrote:

>	context.put( "request", request );
>
>	$request.Parameter.Name
>	$request.Parameter.Password
>	$request.Parameter.FavoriteCheese
>
>-bob
>		
>
>On Fri, 22 Mar 2002, Ken wrote:
>
>>Is this the best way to get all the parameters from a form and
>>put them back into the context, or is there some simpler way
>>that I've overlooked?
>>
>>Enumeration par_names = request.getParameterNames();
>> while(par_names.hasMoreElements()){
>>   String s1 = par_names.nextElement().toString();
>>   ctx.put(s1,request.getParameter(s1));
>> }
>>
>>Thanks,
>>Ken
>>
>>
>>--
>>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>
>
>
>




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


Re: put parameter values back into context?

Posted by bob mcwhirter <bo...@werken.com>.
	context.put( "request", request );

	$request.Parameter.Name
	$request.Parameter.Password
	$request.Parameter.FavoriteCheese

-bob
		

On Fri, 22 Mar 2002, Ken wrote:

> Is this the best way to get all the parameters from a form and
> put them back into the context, or is there some simpler way
> that I've overlooked?
> 
> Enumeration par_names = request.getParameterNames();
>  while(par_names.hasMoreElements()){
>    String s1 = par_names.nextElement().toString();
>    ctx.put(s1,request.getParameter(s1));
>  }
> 
> Thanks,
> Ken
> 
> 
> --
> 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>