Slashdot Mirror


Velocity 1.4 Released

JohnA writes "After what seemed to be a 30 year beta period, the Apache Jakarta team has made available the final release version of Velocity 1.4. If you're not familiar with Velocity, it's one of the most powerful and popular templating engines around. And, as an added bonus, a DreamWeaver plugin was also released."

6 of 29 comments (clear)

  1. Re:Why? by HawkingMattress · · Score: 5, Informative

    Because JSP sucks.
    It is hard to debug, and encourages bad practices like putting some java code directly into the JSP, which then becomes a logic and presentation layer instead of just presentation. JSP is the thing you'd want to create a quick and dirty app, but it's sadly an enterprise standard. Now you can try to force everyone to use it as a sole presentation layer, but in many cases, it's very tempting to juste add a little scriplet, because it gets the job done. Then one day you realize your CMS or whatever has become very hard to maintain because there is logic everywhere and you have to recode the whole thing to keep the maintenance costs low.
    The problem is, that's exactly the type of problem that J2EE is supposed to address, but JSP makes it hard because it's too easy to shoot yourself in the foot.

  2. Re:Why? by aminorex · · Score: 5, Informative

    JSP is horrible because it is designed to produce badly designed code. Bad design, by design. You see, in JSP the crucial, central aspects of presentation and business logic tend to become increasingly intertwined, because there is Java code
    implementing business logic intertwingled with your presentation HTML, and vice versa contrariwise.
    This is not a happy peanut butter cup land.

    PHP and ASP have the same problem. PHP is actually even worse, because, although there are template engines for PHP, they lead to spaghetti objects, where a single aspect is smeared over umpty-booty-teen different class files. Good luck maintaining that when the project grows past 10kloc! (I won't even BEGIN to address the death-march misery that is ASP.NET.)

    Struts, Velocity, and JSF together make a beautiful system, in which the classic MVC patterns apply, aspects are colocated, and presentation is sharply segrated from business logic. Now that, my friend, is a real step ahead of the competition. Websphere is the only commercial environment that really supports this stuff right now, although I expect WebLogic to catch up soon. The Dreamweaver support is velly intelesting to me as well.

    It's a good time to be alive.

    --
    -I like my women like I like my tea: green-
  3. Re:About time... by iroberts · · Score: 4, Informative
    I would recommend Jamon, which is for Java what HTML::Mason is for Perl. Rather than "throwing variables over a wall" from java code to templates via a context object (basically a hash map), templates declare themselves to expect certain arguments, which are passed to them from Java code. For example, HelloWorld.jamon might contain:
    <%args>
    String name;
    </%args>
    Hello <% name %>!
    This would be called from java as
    new HelloWorld().render(System.out, "Taco");
    Any java types can be passed to a template (primatives and objects). Templates can both inherit from and call other templates. Everything is staticly type-checked at compile time. Automatic template recompilation is supported during development, and in production, no reflection is used.
  4. I'd rather use Tapestry by chochos · · Score: 3, Informative

    I think Tapestry (now adopted by jakarta too) is a better replacement for JSP. It's a lot easier to use than Struts, requires less configuration, has a nice plugin for Eclipse (spindle), and has a very elegant design, that allows for a lot of extensibility and reuse while keeping presentation separate from logic. The only drawback, really, is that's it not JSP and some people have a problem with that. Struts as I see it is a patch on top of JSP. JSF, JDO, and some other initiatives by Sun are just attempts to catch up with more advanced, robust and mature open source projects like Tapestry, Hibernate and the like.

    1. Re:I'd rather use Tapestry by chochos · · Score: 3, Informative

      Well, Tapestry looks EXACTLY like HTML. You don't really use any special tags (forget about <%tags%> and and such), you just use a special attribute in the tags you want to process as Tapestry objects, for example you can do this for a page link.
      You can easily write your own components and have them contain other components, etc. It's really versatile and powerful. You can also get the html from a web guy, add the jwcid attributes, give it back to the web guy, etc.

  5. Re:Why? by wglass · · Score: 3, Informative

    A big advantage of Velocity is that it combines a flexible templating language with ease of integration into existing applications and frameworks. Because of this, a lot of java-based web frameworks include Velocity support. Struts, WebWork, Turbine, Maverick, Spring, to name a few. Using Velocity it's also possible to roll your own web markup language with Velocity as a base, as the folks on the Roller team have done.

    In addition, Velocity is more than just a web scripting language. (as opposed to JSP which is almost exclusively that). Besides using it to create web pages in a webapp, I have made Velocity templates to assist my applications in sending email and have made templates to auto-generate code to help with my object/relational mapping. There's also a translation to C# called NVelocity.