The Jakarta Project < Velocity Tools - Struts >

Velocity Tools

VelocityStruts

VelocityStruts Tools

その他のサブプロジェクト

概要
       

The VelocityStruts sub-project integrates Velocity with the Jakarta Struts Web application framework and enables the use of velocity templates interchangeably with JSP pages for the view layer.

VelocityStruts サブプロジェクトは Velocity と Jakarta Struts Web アプリケーションフレームワークとを統合し、 ビューレイヤとして JSP の代わりに Velocity テンプレートを使用することを可能にします。

Various other web application frameworks offer built-in support for Velocity templates. This project provides the minimal glue necessary to give Struts developers an alternative to JSP.

多様多種の Web アプリケーションフレームワーク が Velocity テンプレートをサポートしています。 このプロジェクトでは、 Struts 開発者に JSP の代わりとなる必要最小限のセットを提供します。

Diagram 1. Comparison of JSP and Velocity for the view layer in a Struts application.

図 1. Struts アプリケーションのビューレイヤにおける、 JSP と Velocity の比較。

As we follow the typical Struts process flow in Diagram 1, notice how there is relatively little change except for the addition of Velocity. The velocity-struts.jar leverages a standalone Velocity servlet to process template files (specifically, the jar file is velocity-tools-x.x.jar) and uses some drop-in tools to provide transparent access to Struts specific objects (ex. message resources, form beans, errors, links). The action mapping file will simply contain ActionForwards that send control to a Velocity-based View layer instead of sending to a JSP.

図1の典型的な Struts の処理フローでは、 Velocity が追加されることを除けば比較的小さな変更だということに気づくでしょう。 velocity-struts.jar はテンプレートファイルを処理するスタンドアロンの Velocity サーブレット(具体的には、 velocity-tools-x.x.jar という JARファイルです)、 Struts 固有のオブジェクト(例: メッセージリソース、フォームビーン、エラー、リンク) への透過的なアクセスを提供するいくつかのツールを使用します。 アクションマッピングファイルは制御を JSP の代わりに Velocity ベースのビューレイヤへ渡す ActionForward を含んでいます。

Also notable is that Velocity and JSP are not mutually exclusive. Both technologies can be used in the same application without any problems. This allows developers the option of trying Velocity without heavy modification to existing applications.

さらに、注目すべきは Velocity と JSP は排他的ではないということです。 何の問題も無しに、両方のテクノロジを同一アプリケーション内で使用することができます。 既存のアプリケーションに大きな変更を入れることなく、 開発者が Velocity を試すことが可能です。

We're convinced that once you give Velocity a try, you'll really like it.

一度 Velocity を試してみれば、きっと病みつきになると思いますよ!

利点
       

There are many different reasons why people are choosing Velocity technology for the view layer. Here are some:

人々がビューレイヤに Velocity を選択するのにはさまざまな理由があります。 いくつか挙げますと:

  • Velocity helps enforce a clean separation between the view layer and the model/control layers. This leads to clean application design and a clear separation of concerns between View Designers and back-end Developers.
  • Velocity Template Language (VTL) has few directives and is simple and easy to learn. Most people report being productive within a day.
  • Velocity is easy to extend with Tools which are simply any class which has public methods. These are typically much cleaner and easier to develop than JSP custom tag libraries.
  • Using the new TilesTool it is now possible to mix Velocity and JSP tiles in the same page/layout. For those using Tiles, this makes gradual migration between or integration of the two view technologies trivially easy!
  • Velocity 'macros' are a powerful tool for the View Designer. They enable the creation of reusable snippets of markup, often eliminating what would have been a need to develop a custom tag library or other server-side tool.
  • Velocity templates are not limited to HTML and can be used to produce any type of text output including XML, SQL, ASCII, PostScript, etc.
  • Velocity enables easy access to dynamic data that Web Designers can understand.
  • Velocity being interpreted, enables a simple development cycle where template errors can quickly be localized and debugged.
  • Velocity, which caches templates for speed, has been reported to have performance comparable or better than JSP.
  • Velocity is supported by an active and helpful community of users and developers.

  • Velocity はモデル/コントロールレイヤから、 ビューレイヤを明確に分離することを強制します。 これはアプリケーションの設計をクリーンにし、 ビューデザイナとバックエンドの開発者を明確に分離します。
  • Velocity テンプレート言語 (VTL) は構文が少なく、シンプルで簡単に覚えられます。 多くの人は一日で使えるようになったと言っています。
  • Velocity は public メソッドをもつただのクラスである ツール によって簡単に拡張することができます。 これは、 JSP のカスタムタグライブラリよりすっきりしており、 より簡単に作ることができます。
  • 新しく追加された TilesTool により、Velocity と JSP のタイルを同じページ/レイアウトに混在させることができます。 Tiles を使用している人にとっては、 この二つの技術間を徐々に移行することや統合することは驚くほど簡単です!
  • Velocity の 'マクロ' はビューデザイナのための強力なツールです。 これは再利用可能なマークアップの断片を定義するもので、 カスタムタグライブラリやその他のサーバサイドで利用するツールの開発の必要性を無くしてくれるものです。
  • Velocity テンプレートの適用範囲は HTML だけに限られるものではありません。 XML, SQL, ASCII, PostScript 等、 あらゆるテキストの出力の生成に使用することが可能です。
  • Velocity は Web デザイナが理解できる、 動的データへの簡単なアクセス方法を提供します。
  • Velocity はインタプリタであり、テンプレートのエラーは即座に発見・ デバッグすることができ、シンプルな開発サイクルを可能にします。
  • Velocity は処理速度向上のためにテンプレートをキャッシュしており、 そのパフォーマンスは JSP を上回ると言われています。
  • Velocity は活動的で助けになる、ユーザと開発者の コミュニティによって支えられています

成功話
       

Comments from folks who are using Struts and Velocity:

Struts と Velocity を使用している人たちからのコメント:

"We've been using Struts/Velocity for some time now and we find it to be an extremely well matched combination. One of the main advantages of Velocity is that the syntax is incredibly easy. I can explain it to a designer who has never seen it before and expect them to be useful within an hour."

"One of the nicest things it enforces is the separation of presentation layer and business logic. It removes the desire to 'fix' problems by just putting a small change into the JSP via scriptlets. It also makes the code a lot more readable which also reduces the development time."

"Struts is a solid framework and Velocity makes it even better."

"I find that the Velocity Tools for Struts works as well, or better, with Struts than another other presentation technology, bar none. In fact, most of the tools work just as well with any other framework you might care to name." --Ted Husted (author of Struts in Action)

"私たちはもうかなりのの間、 Struts/Velocity を使用しており、 それが相性の良い組み合わせであることを認識した。 Velocity の主な利点のうちの1つは、文法が信じられないほどに 簡単であるということだ。Velocity 初体験のデザイナに、 使い方を1時間以内で説明することだって可能だろう。"

"Velocity の利点の一つは、 プレゼンテーションレイヤとビジネスロジックの分離を強制することなんだよ。 これは、JSP にスクリプトレットを埋め込んで、 問題を解決してしまおうという欲求を断ち切ってくれる。 さらに、コードの可読性をより向上させ、 開発期間を短縮してくれるんだ。"

"Struts はしっかりしたフレームワークで、 Velocity はそれをさらによりよいものにしてくれる。"

"Velocity Tools は他のどんなプレゼンテーション技術と同様、 またはよりよく Struts と統合できると思えます。例外はありません。 実際、そのほとんどのツールは思いつくどんなフレームワークとも同様に統合できます。" --Ted Husted (Struts in Actionの著者)

ライセンス
       

This software is licensed under the Apache Software License

このソフトウェアには Apache Software License が適用されます。


[訳注: この文書は Shinobu Kawai 木村 貴由 が翻訳しました。 日本語訳に対するコメントがあれば、report@jajakarta.orgに送って下さい。]
Copyright © 1999-2003, Apache Software Foundation