velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Fahrmeyer" <>
Subject RE: automatic context filling ??
Date Wed, 07 Feb 2001 16:37:45 GMT

what I want to have is may be application specific, but I asked that because
I think that
functionality is already implemented in Velocity. If a variable $
is in the template, Velocity have to find the object in the context, and
call the getName Method.

The mechanism to find objects,subobjects and properties is there. I just
want to use this mechanism to address a object in the context with
"". Then call setName(given value) instead of getName like the
template engine it does.

I don't want to integrate such funtionality into Velocity's utility classes,
but I want implement it by myself. I want to know which classes are involved
in recognizing the objects in the context and calling the appropriate

The form refilling I wanna implement should do the following:
1. all my form input fields have names like "" (corresponding to
reading values out of the context)
2. to put the values from the form fields into the context once again (for a
re-displaying if the form data are not valid) I want read the value with
	value = request.getParameter("")

and  store it in the context with:

	fillContext(context, "", value);

Context contains all the object I want to modify.

This process can just implemented in a loop and I have not worry about
reading and setting the values in context. If the template is displayed once
again I'll get all the prefilled values for the form fields. (form field
values are defined with: value="$")

Is that a bad approach ?

To Steve: ParameterParser could be a solution, but what about aggregated
objects like:
and I want to acces the "street" from the address: user.address.street ??

Another short question to Turbine: I missed a good way to control the screen
flow (or just not found ;), like Struts it provides. Is there something
similar ?


-----Original Message-----
From: Geir Magnusson Jr. []
Sent: Tuesday, February 06, 2001 6:28 PM
Subject: RE: automatic context filling ??

More inline...
> -----Original Message-----
> From: Thomas Fahrmeyer []
> Sent: Tuesday, February 06, 2001 10:42 AM
> To: Velocity-User
> Subject: automatic context filling ??
> Hi,
> is there a way to do the following:
>       UtilityClass.fillContext(context, "", "scott");
In Java?  Why not just set your objects *before* putting them into the
If I am reading this right, it sounds like an application design issue more
than a deficiency in the Velocity toolset.
Can you explain this again if I didn't get it?
> It should do: Look in the given context for a object named
> "user", then call
> setName("scott")
> That would be very cool. I wanna use it to pre-fill a form. I
> want to create
> a context and put all the
> inital objects like "user" into that context. Then validate
> the form data.
> If the form is invalid I would like to do:
>       String value = request.getParameter("") //
> because all the form
> elements are named like the
>        // Velocity context objects
>       UtilityClass.fillContext(context, "", value);
> Then I use this context to display the data in the template.
> I know you are confused once again ;), but I think you can
> imagine what I
> wanna have.
> How can I achieve that, which classes are involved. Can I
> customize Velocity
> behavior.
> bye
> Thomas
>       (O) (O)
> ----^^^  °  ^^^--------------------------
> Das was wir haben, können wir verlieren
> durch den masslosen Wunsch nach mehr.
> -----------------------------------------

View raw message