tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nick Bauman" <n...@cortexity.com>
Subject Re: Taglibs Article
Date Sat, 26 May 2001 02:05:23 GMT
> Now, I wonder if I could successfully rekindle a Velocity vs. JSP
> flamewar ... <evil grin> ... don't ask me, I'm strictly a servlet guy.
> Mixing business and presentation logic is exhilirating, kinda like
> running with scissors or jumping in the pool less than 30 minutes after
> a meal.
> 
> - Christopher

I'm having a lot of fun with Velocity right now. It has a distinct advantage
over JSP in one area for me: it'll run outside of a Servlet Container
easily, and very nicely thank you.

As far as mixing presentation logic and business logic together, well, you
can do that with Velocity, too. Although it makes you think longer and
harder about it. Here's a recent template snippet I wrote. This is something
you wouldn't necessarily be proud of doing with Velocity.

----8<----

#foreach( $event in $events )
  $yapper = $meeting.getParticipation( ((MeetingEvent)$event).getFromId() ) 
  #if( $repRole.equals($yapper.getRole() )
    $repId = $yapper.getParticipantId()
    <font color="$black"><b>$yapper.getName()</b></font>
  #else
    <font color="$blue"><b>$yapper.getName()</b></font>
  #end
  #if ( $event.getClass().getName().equals($chatEventType) )
    ((com.webhelp.emeeting.events.ChatEvent)$event).getStoredData() <br>
  #else if( $event.getClass().getName().equals($urlPushedEventType) )
    <a
href="((com.webhelp.emeeting.events.URLPushedEvent)$event).getStoredData()">((com.webhelp.emeeting.events.URLPushedEvent)$event).getStoredData()</a><br>
  #end
#end

----8<----

Although I think I can clean this up a lot using #macro, it shows how you
can use the dark side of the force even with a great tool like Velocity.

-- 
Nick Bauman
Software Developer
3023 Lynn #22
Minneapolis, MN
55416
Mobile Phone: (612) 810-7406


Mime
View raw message