You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Geir Magnusson Jr." <ge...@earthlink.net> on 2002/01/11 23:34:35 UTC

Re: Manipulating a Context after the Merge (was: Re: LDAP Context?)

On 1/11/02 4:52 PM, "Andrew Smith" <as...@wpequity.com> wrote:

>> If it were me, I would agree on a datastore-neutral 'API' or 'data contract'
>> (agreement on what data is needed and what it is named in the context)
> 
> OK, fair enough. Let's assume that I have a little class called
> LDAPSearch that takes RFC1558 filters and returns an iterator over some
> result set. 
> 
> If I put an LDAPSearch object into my context is there ever a way to
> give the template author the ability to call that method and iterate
> over the results? It seems to me that this must all be done in the setup
> code and once you call template.merge your context is pretty much shot.
> 
> e.g. a template might look like this
> 
> ------------------------------------
> $ldapsearch.search("employer=Ford")
> 
> #foreach ($person in $searchResults)
> carmaker: $person.get('name')
> #end
> 
> $ldapsearch.search("employer=Rawlings")
> 
> #foreach ($person in $searchResults)
> glovemaker: $person.get('name')
> #end
> 
> etc...
> ------------------------------------
> 

That's better - you still tied it to ldap explicitly, but that's minor.

That would work fine though (forgetting the tying part)

> How would this work in Velocity? Would you need to preload the result
> sets into the context?

That's up to you - you don't have to do that, so the template author can
specify what they want, if you feel that's appropriate.

This is a much better approach, as you now can change the source of the
data....

> I guess the question boils down to this: does the
> template author have any influence over the context object given to him?

Yes - it's really up to you - the above would work fine, and the template
designer could call for data as he/she needs it...

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



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