velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Colson" <>
Subject RE: [VelStruts] FieldMethodizer() question
Date Mon, 11 Mar 2002 18:13:09 GMT
Tom -
  I may be daft, but perhaps the FieldMethodizer could be overridden to
place the constants directly into the context for the template. This
would work in the current design and not automatically expose all fields
(which last I heard wasn't proper OO design either. <grin>)

For example:
>     public final static int PAST30DAYS  = 3;
>     public final static int CREATES     = 0;
>     public final static int ALL         = 0;

>     NTUserAccountTrxStatistics stat = ei.getNTUsrAcctStatistics();
>     request.setAttribute("TrxStatistics", stat);
>     request.setAttribute("TrxStatConst", new

TimsFieldMethodizer would somehow magically automate these manual steps:
  request.setAttribute("PAST30DAYS", PAST30DAYS);
  request.setAttribute("CREATES", CREATES);
  request.setAttribute("ALL", ALL);

> in Velocity template ...
>     <TD>$TrxStatistics.getValue($TrxStatConst.PAST30DAYS,
> $TrxStatConst.CREATES, $TrxStatConst.ALL)</TD>

Would then become:
>     <TD>$TrxStatistics.getValue($PAST30DAYS,$CREATES, $ALL)</TD>

Caveat would be, collapsing namespaces like this would make for
potential collisions e.g. Foo.ALL and Bar.ALL -> $ALL would presumably
be the LAST-IN value. 


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message