velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Charles N. Harvey III" <charl...@alloy.com>
Subject RE: put parameter values back into context?
Date Mon, 25 Mar 2002 15:44:04 GMT
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:
> >>> <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> >>> For additional commands, e-mail:
> >>> <mailto:velocity-user-help@jakarta.apache.org>
> >>>
> >>
> >>
> >> --
> >> To unsubscribe, e-mail:
> >> <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> >> For additional commands, e-mail:
> >> <mailto:velocity-user-help@jakarta.apache.org>
> >>
> >>
> >>
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:velocity-user-help@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:
<mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:velocity-user-help@jakarta.apache.org>


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


Mime
View raw message