velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leos Literak <liter...@centrum.cz>
Subject Re: summary table of velocity reflection?
Date Sat, 10 Aug 2002 11:38:57 GMT
>> public constructors, with args:
>>  not available
>>  workaround: add a public static method to the class or a helper class
> 
> Yep - the idea is to provide all the objects necessary for the designer, not
> let them create them.
> 

Generally I agree. But see my example:

in the template I want to display the freshest
titles of articles on different servers.

Slashdot
* Article 1
* Article 2

Linux PR
* PR article 1
* PR article 2

and so on.

I fetch this data into class Server (simplification)
There are currently 6 newest articles for many servers.
But in the template, which is displayed on every
page I choose, which servers gets diplayed and how
many titles will appear there.

So I use this:

#set($servers=[])
$!servers.add($UTIL.instantiate('Server',5))
$!servers.add($UTIL.instantiate('Server',1))
##$!servers.add($UTIL.instantiate('Server',6))

and

#foreach($server in $servers)
#sync($server)
#set($links=$UTIL.sublist($UTIL.sortByDateDescending($LINKS.get($server)),0,2))
#foreach($link in $links)
<TR>
<TD><A CLASS="menu" HREF="$!link.Url">$!link.Text</A></TD>
</TR>
#end
#end

So I instantiate variables in template (when I am in role
of designer :-), but I do designer's job. Such limitation
of data is IMHO responsability of designer. I cannot imagine,
that I had to recompile classes, whenever I decide to
stop displaying titles of some server.

Yes, it would be nice to have other solution
that I presented there. Something like
#set($tmp=[5 1])
#set($servers=$TOOLS.getServers($tmp))

but when I implemented this part, I had some issues
with arrays (dont remember what kind of).

So if there would be kind of nice way how to
instantiate objects (with or without parameters),
I would be very happy :-)

	Leos

-- 
Leos Literak
http://AbcLinuxu.cz - tady je tucnakum hej!




--
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