<?xml version="1.0" encoding="Shift_JIS"?>
<!--
  Copyright 2003-2004 The Apache Software Foundation.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

  $Id: userguide.xml,v 1.7 2005/03/19 07:58:22 nekop Exp $
-->
<document>

    <properties>
        <title>ユーザガイド</title>
        <author email="sidler@apache.org">Gabriel Sidler</author>
        <projectfile>xdocs-ja/struts/menu.xml</projectfile>
        <translator email="shinobu@ieee.org">Shinobu Kawai</translator>
        <translator email="nose@intellilink.co.jp">野瀬直樹</translator>
        <original>User Guide</original>
    </properties>

    <body>

    <section name="VelocityStruts User Guide" alias="VelocityStruts ユーザガイド">

        <primary>
        <p>This guide explains how to setup and configure a VelocityViewServlet
        which can render the views of a Struts-based web application. The servlet
        will create a VelocityEngine to render *.vm (velocity template) files using
        contextual information provided by a Struts Controller action.</p>
        </primary>
        <p>このガイドでは、Struts ベースの Web アプリケーションのビューのレンダリングを行う
        VelocityViewServlet のセットアップと設定の方法について説明します。
        このサーブレットは Struts のコントローラにより提供される情報を元に、
        *.vm (Velocity テンプレート) ファイルをレンダリングする
        VelocityEngine を作成します。</p>

        <primary>
        <p>A set of built-in tools have been created which provide the same
        functions as the Struts JSP Tag libraries for Tiles, Validator, forms, links,
        messages, and errors.</p>
        </primary>
        <p>いくつかのビルトインツールが作成されました。
        これらはTiles、Validator、フォーム、リンク、メッセージ、
        エラーのためのStruts JSPタグライブラリと同じ機能を提供します。</p>

        <primary>
        <p>The distribution contains examples which demonstrate the use of the
        built-in Struts tools. The examples are packaged into a web archive file
        (velstruts.war). </p>
        </primary>
        <p>配布物には Struts ツールの使用例が含まれています。
        この例は Web アーカイブファイル (velstruts.war) にパッケージングされています。</p>

        <primary>
        <p>
        This document is <strong>not</strong> a general introduction to the Velocity
        template language and its syntax. If you are new to Velocity, please consult
        <a href="http://jakarta.apache.org/velocity/getting-started.html">Getting
        Started with Velocity</a>.
        </p>
        </primary>
        <p>
        このドキュメントは Velocity テンプレート言語
        やその文法を紹介するもの<strong>ではありません</strong>。
        もし Velocity を触るのが初めてならば、
        <a href="http://jakarta.apache.org/velocity/getting-started.html">Velocity を使い始める</a> を参照しておいてください。
        </p>

        <primary>
        <p><strong>Table of Contents</strong></p>
        <ol>
          <li><a href="#Background">Background</a></li>
          <li><a href="#Model 2 Architecture">Model 2 Architecture</a></li>
          <li><a href="#Installation">Installation</a></li>
          <li><a href="#Rendering the View">Rendering the View</a>
            <ol>
                <li><a href="#Velocity Template Language">Velocity Template Language</a></li>
                <li><a href="#Exposing Data">Exposing Data</a></li>
                <li><a href="#Access to Servlet Resources">Access to Servlet Resources</a></li>
                <li><a href="#Access to Struts Framework Resources">Access to Struts Framework Resources</a></li>
                <li><a href="#View Tools">View Tools</a></li>
            </ol>
          </li>
        </ol>
        </primary>
        <p><strong>目次</strong></p>
        <ol>
          <li><a href="#Background">背景</a></li>
          <li><a href="#Model 2 Architecture">Model 2 アーキテクチャ</a></li>
          <li><a href="#Installation">インストール</a></li>
          <li><a href="#Rendering the View">ビューの表示</a>
            <ol>
                <li><a href="#Velocity Template Language">Velocity テンプレート言語</a></li>
                <li><a href="#Exposing Data">データを渡す</a></li>
                <li><a href="#Access to Servlet Resources">サーブレットリソースへのアクセス</a></li>
                <li><a href="#Access to Struts Framework Resources">Strutsフレームワークリソースへのアクセス</a></li>
                <li><a href="#View Tools">ビューツール</a>(訳注: このリンク先は存在しません。
                最新のドキュメントではこのリンクは削除されています。)</li>
            </ol>
          </li>
        </ol>

        <br clear="all"/>
    </section>

    <section name="Background" alias="背景">
        <primary>
        <p>The documentation will explain the steps necessary to
        integrate <a href="http://jakarta.apache.org/velocity/">Velocity</a>
        with <a href="http://jakarta.apache.org/struts/">Struts</a> applications.
        It is expected that the reader already has a basic understanding of those
        projects.</p>
        </primary>
        <p>このドキュメントは
        <a href="http://jakarta.apache.org/velocity/">Velocity</a> を
        <a href="http://jakarta.apache.org/struts/">Struts</a>
        アプリケーションと統合するのに必要なステップを説明します。
        読者はすでにこれらのプロジェクトの基本的な部分を理解していることを前提とします。 </p>

        <primary>
        <p>To start working with Velocity and Struts we recommend reading the
        user guide, installing and browsing the example applications and reference
        documentation, then installing the VelocityStruts view layer into your own
        application.</p>
        </primary>
        <p>Velocity と Struts を始める前に、ユーザガイドを読み、
        アプリケーション例とリファレンスガイドをインストールして眺め、
        それから VelocityStruts をあなたのアプリケーションのビューレイヤとして使用することをお勧めします。</p>

        <primary>
        <p>If this documentation does not answer all your questions, please post
        questions to the
        <a href="http://jakarta.apache.org/site/mail.html">Velocity-User mailing list</a>
        and we'll be happy to help! (And we'll update this doc!)</p>
        </primary>
        <p>もしこのドキュメントがあなたの疑問を解決しきれないと判断したら、
        質問を <a href="http://jakarta.apache.org/site/mail.html">Velocity-User メーリングリスト</a> にポストしてください。
        喜んで手助けします! (そしてドキュメントを改良していきます!)</p>        

        <br clear="all"/>
    </section>

    <section name="Model 2 Architecture" alias="Model 2 アーキテクチャ">
        <primary>
         <p>In the JSP world, the terms <i>Model 1</i> architectures and
         <i>Model 2</i> architectures were coined to refer to particular ways of
         designing and building web applications. It is important that you understand
         the fundamental difference between these two architectural approaches. JSP
         can be used in applications designed after Model 1 architectures as well as
         Model 2 architectures. Velocity cannot. It has been designed very consciouly
         as a view technology for web application architectures based on Model 2.</p>
        </primary>
         <p>JSP の世界では、 <i>Model 1</i> アーキテクチャと
         <i>Model 2</i> アーキテクチャが Web アプリケーションの設計、
         製造の方法として確立されました。
         この2つの設計アプローチの基本的な違いを理解することは重要です。
         JSP は Model 2 アーキテクチャだけではなく、
         Model 1 アーキテクチャとして設計された Web アプリケーションでも使用することができます。
         Velocity は違います。
         Velocity は Model 2 に基づく Web アプリケーションアーキテクチャのビューテクノロジとして設計されました。</p>

        <primary>
         <p><strong>Model 1 Architectures</strong></p>
        </primary>
         <p><strong>Model 1 アーキテクチャ</strong></p>
        <primary>
         <p>In a Model 1 architecture, the JSP page alone is responsible for
         processing the incoming request and replying back to the client. Using
         MVC speak, the controller and the view  are implemented within the same
         JSP page. Model 1 architecture are suitable only for very simple application
         scenarios. In medium size to large projects, the lack of a separation between
         business logic and view oftentimes leads to difficulties in separating the
         web designer's works from the server developer's work and causes project
         management headaches.</p>
        </primary>
         <p>Model 1 アーキテクチャでは、単体の JSP ページで、
         リクエストを処理しクライアントにレスポンスを返します。
         MVC でいうところの、コントローラおよびビューが、
         同じJSPページ内に実装されています。
         Model 1 アーキテクチャは非常に単純なアプリケーションのシナリオのみに適します。
         中規模から大規模のプロジェクトでは、
         ビジネスロジックとビューの間の分離がきちんとできていないことが、
         サーバ開発者の仕事から Web デザイナの仕事を分ける際の困難さに結びつき、
         プロジェクト管理の頭痛の種となります。</p>

        <primary>
         <p><strong>Model 2 Architectures</strong></p>
        </primary>
         <p><strong>Model 2 アーキテクチャ</strong></p>
        <primary>
         <p>In a Model 2 architecture, the control component, including business logic,
         data access and request handling, are strictly separated from the view component.
         The view does not contain any processing logic. It is simply responsible for
         displaying the data that resulted from processing the request. This may be a
         static page or more often a dynamic page. Such an approach typically facilitates
         are clear delineation of the roles and responsibilities of the developers and
         the web designers. The more complex an application, the greater the benefits of
         using a Model 2 architecture will be.</p>
        </primary>
         <p>Model 2 アーキテクチャでは、ビジネスロジック、データアクセス、
         リクエストハンドリングを含むコントロールコンポーネントはビューコンポーネントから明確に分離されます。
         ビューはいかなる処理ロジックも含みません。
         リクエストの処理結果であるデータの表示を行うだけです。
         これは静的なページであることもありますが、大抵は動的なページとなるでしょう。
         このようなアプローチは一般的に、
         開発者および Web デザイナの役割や責任の明瞭な線引きを促します。
         アプリケーションがより複雑であるほど、
         Model 2 アーキテクチャを使用する利点はより大きいものとなるでしょう。</p>

        <primary>
         <p>The paper
         <a href="http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html">Understanding JavaServer Pages Model 2 Architecture</a>
         provides a more in-depth discussion of Model 1 and Model 2 architectures.</p>
        </primary>
         <p><a href="http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html">JavaServer Pages Model 2 アーキテクチャを理解する</a>
         で Model 1 と Model 2 アーキテクチャのより深い議論が提供されています。</p>

        <primary>
         <p><strong>What does this mean?</strong></p>
        </primary>
         <p><strong>これは何を意味するの?</strong></p>
        <primary>
         <p>The Struts framework can support both architectures, but all the
         facilities it provides are really aimed at making the construction of
         Model 2 applications easy. Velocity on the other hand cannot be used
         to build Model 1 architectures. It lacks the libraries to support such
         a design. I am emphasizing this here because I want to make sure that
         you have all the relevant facts before you decide on Velocity for your
         projects. This is especially important for people considering to port
         existing application built on the Model 1 approach or a mixed Model 1
         / Model 2 approach. The good news is, that today for any serious application
         Model 2 is state of the art and Velocity will support you very well on
         that route.</p>
        </primary>
         <p>Struts フレームワークは両方のアーキテクチャをサポートしていますが、
         実際には提供される機能はすべて Model 2
         アプリケーションの構築を容易にすることが目的です。
         Velocity はそうではなく、Model 1
         アーキテクチャでは使用することができません。
         そのような設計を支援するライブラリがないのです。
         あなたが Velocity をプロジェクトに採用することを決定する前に、
         このような事実をすべて把握していることを確認するため、
         ここで強調しておきます。
         これは、 Model 1 アプローチあるいは Model 1 / Model 2
         混合アプローチ上で構築された既存のアプリケーションを移植することを検討している人々には特に重要です。
         最後に、良いお知らせです。
         現在の本格的なアプリケーションでは Model 2 は最先端技術であり、
         この手法を用いる限り、 Velocity はあなたの力強い味方となるでしょう。</p> 

         <br clear="all"/>
    </section>

    <section name="Installation" alias="インストール">

        <primary>
        <p>This section explains the basic setup to configure the VelocityViewServlet
        to render the web application views in Struts applications.</p>
        </primary>
        <p>この章では Struts Web アプリケーションのビューの表示を行えるように、
        VelocityViewServlet を設定する基本的なセットアップ方法を説明します。</p>

        <primary>
        <p>Setup is almost identical to the standard
        <a href="../view/index.html#Installation">VelocityViewServlet installation</a>,
        please review that for more details. The extended VelocityLayoutServlet, or any
        custom extension, can also be used with Struts. (That particular servlet adds
        the ability to reuse shared html layout across multiple pages.)</p>
        </primary>
        <p>セットアップの手順は普通の <a href="../view/index.html#Installation">VelocityViewServlet のインストール</a>とだいたい一緒です。
        より詳細については見直しておいてください。
        拡張したものである VelocityLayoutServlet や、
        他のカスタム実装も Struts で使用することができます。
        (このサーブレットは、 html レイアウトを複数のページで共有し、
        再利用する機能が加えられています。)</p>

        <primary>
        <p>Steps by step:</p>
        </primary>
        <p>ステップバイステップ:</p>
        <primary>
        <ol>
          <li><strong>velocity-tools-x.x.jar</strong> which contains the VelocityStruts
          and VelocityView classes must be added to the WEB-INF/lib directory.</li>
          <li>VelocityViewServlet needs to be installed into the servlet container
          (web.xml) so it can handle all request for *.vm files.</li>
          <li>velocity.properties configuration file must be added </li>
          <li>toolbox.xml file must be added, and mappings must be setup for the
          standard tools which expose the Struts objects to the template. (sample
          toolbox.xml file below)</li>
        </ol>
        </primary>
        <ol>
          <li><strong>velocity-tools-x.x.jar</strong> は
          VelocityStruts と VelocityView のクラス群を含んでいるものであり、
          WEB-INF/lib に配置します。</li>
          <li>*.vm ファイルへのリクエストを処理する VelocityViewServlet を、
          サーブレットコンテナにインストールする
          (web.xml への記述) 必要があります。</li> 
          <li>設定ファイル velocity.properties を追加する必要があります。</li>
          <li>toolbox.xml ファイルを追加し、
          Struts オブジェクトをテンプレートから利用できるようにするための、
          標準ツールのマッピングをセットアップします。
          (toolbox.xml ファイルのサンプルが下にあります。)</li>
        </ol>
        <primary>
        <p>And that's all there is to it!</p>
        </primary>
        <p>これで全部です!</p>
        <primary>
        <p>At this point, it should be possible to change a Struts ActionMapping
        to 'forward' to a *.vm file placed in the webapp root directory and have
        it be displayed!</p>
        </primary>
        <p>ここまで終われば、 Struts ActionMapping の
        'forward' を Web アプリケーションのルートディレクトリに配置されている
        *.vm ファイルへ変更するすることで、
        それを表示することが可能となっているはずです!</p>

             <p><b>toolbox.xml</b></p>
<sourcecode>
&lt;?xml version="1.0"?&gt;

&lt;toolbox&gt;
  &lt;tool&gt;
     &lt;key&gt;link&lt;/key&gt;
     &lt;scope&gt;request&lt;/scope&gt;
     &lt;class&gt;org.apache.velocity.tools.struts.StrutsLinkTool&lt;/class&gt;
  &lt;/tool&gt;
  &lt;tool&gt;
     &lt;key&gt;msg&lt;/key&gt;
     &lt;scope&gt;request&lt;/scope&gt;
     &lt;class&gt;org.apache.velocity.tools.struts.MessageTool&lt;/class&gt;
  &lt;/tool&gt;
  &lt;tool&gt;
     &lt;key&gt;errors&lt;/key&gt;
     &lt;scope&gt;request&lt;/scope&gt;
     &lt;class&gt;org.apache.velocity.tools.struts.ErrorsTool&lt;/class&gt;
  &lt;/tool&gt;
  &lt;tool&gt;
     &lt;key&gt;form&lt;/key&gt;
     &lt;scope&gt;request&lt;/scope&gt;
     &lt;class&gt;org.apache.velocity.tools.struts.FormTool&lt;/class&gt;
  &lt;/tool&gt;
  &lt;tool&gt;
     &lt;key&gt;tiles&lt;/key&gt;
     &lt;scope&gt;request&lt;/scope&gt;
     &lt;class&gt;org.apache.velocity.tools.struts.TilesTool&lt;/class&gt;
  &lt;/tool&gt;
  &lt;tool&gt;
     &lt;key&gt;validator&lt;/key&gt;
     &lt;scope&gt;request&lt;/scope&gt;
     &lt;class&gt;org.apache.velocity.tools.struts.ValidatorTool&lt;/class&gt;
  &lt;/tool&gt;
&lt;/toolbox&gt;
</sourcecode>

        <br clear="all"/>
    </section>

    <section name="Rendering the View" alias="ビューの表示">

        <primary>
        <p>This section introduces you to the key concepts of rendering
        the view with Velocity in a Struts application.</p>
        </primary>
        <p>この章では、 Struts アプリケーションで Velocity
        を利用してビューを表示させる際の概念の手ほどきを行います。</p>

        <subsection name="Velocity Template Language" alias="Velocity テンプレート言語">

            <primary>
            <p>Velocity is a template engine implemented in Java. Velocity
            templates typically are HTML pages with embedded scripts (although
            Velocity has been used for many other application scenarios). Scripts
            are written in the Velocity Template Language (VTL). Following is a
            simple example of a HTML view with embedded VTL statements:</p>
            </primary>
            <p>Velocity は Java で実装されたテンプレートエンジンです。
            Velocity テンプレートは、
            主に埋め込みスクリプト入りの HTML ページです
            (Velocity は他の多くのアプリケーションシナリオのために使用されてもいますが)。
            スクリプトは Velocity テンプレート言語 (VTL) で記述されます。
            下記は VTL ステートメントを埋め込んだ HTML のシンプルな例です:</p>

            <primary>
<sourcecode>
&lt;HTML&gt;
&lt;BODY&gt;
    &lt;h2>Order Confirmation&lt;/h2&gt;

    &lt;h3&gt;Delivery Adress:&lt;/h3&gt;&lt;br&gt;
    Name: $customer.name&lt;br&gt;
    Street: $customer.street&lt;br&gt;
    City: $customer.zip $customer.city

    &lt;h3&gt;Ordered Items&lt;/h3&gt;&lt;br&gt;
    &lt;table&gt;
    #foreach( $item in $order.items )
        &lt;tr&gt;
            &lt;td&gt;$item.quantity&lt;/td&gt;
            &lt;td&gt;$item.description&lt;/td&gt;
        &lt;/tr&gt;
    #end
    &lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</sourcecode>
            </primary>
<sourcecode>
&lt;HTML&gt;
&lt;BODY&gt;
    &lt;h2>注文の確認&lt;/h2&gt;

    &lt;h3&gt;送付先住所:&lt;/h3&gt;&lt;br&gt;
    名前: $customer.name&lt;br&gt;
    番地: $customer.street&lt;br&gt;
    市: $customer.zip $customer.city

    &lt;h3&gt;注文の品&lt;/h3&gt;&lt;br&gt;
    &lt;table&gt;
    #foreach( $item in $order.items )
        &lt;tr&gt;
            &lt;td&gt;$item.quantity&lt;/td&gt;
            &lt;td&gt;$item.description&lt;/td&gt;
        &lt;/tr&gt;
    #end
    &lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</sourcecode>

            <primary>
            <p>When processed this will produce output similar to the following.</p>
            </primary>
            <p>処理後、下記のような出力となります。</p>

            <primary>
<sourcecode>
&lt;HTML&gt;
&lt;BODY&gt;
    &lt;h2>Order Confirmation&lt;/h2&gt;

    &lt;h3&gt;Delivery Adress:&lt;/h3&gt;&lt;br&gt;
    Name: Peter Pan&lt;br&gt;
    Street: Crain St. 10&lt;br&gt;
    City: 60201 Evanston IL

    &lt;h3&gt;Ordered Items&lt;/h3&gt;&lt;br&gt;
    &lt;table&gt;
        &lt;tr&gt;
            &lt;td&gt;1&lt;/td&gt;
            &lt;td&gt;Hair Dryer, Philips, 1000W, white&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;1&lt;/td&gt;
            &lt;td&gt;Kitchen Mixer, Betty Bossy, 240W, black&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</sourcecode>
            </primary>
<sourcecode>
&lt;HTML&gt;
&lt;BODY&gt;
    &lt;h2>注文の確認&lt;/h2&gt;

    &lt;h3&gt;送付先住所:&lt;/h3&gt;&lt;br&gt;
    名前: Peter Pan&lt;br&gt;
    番地: Crain St. 10&lt;br&gt;
    市: 60201 Evanston IL

    &lt;h3&gt;注文の品&lt;/h3&gt;&lt;br&gt;
    &lt;table&gt;
        &lt;tr&gt;
            &lt;td&gt;1&lt;/td&gt;
            &lt;td&gt;Hair Dryer, Philips, 1000W, white&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;1&lt;/td&gt;
            &lt;td&gt;Kitchen Mixer, Betty Bossy, 240W, black&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</sourcecode>

            <primary>
            <p>VTL has been designed from the ground up as a simple template
            language for view designers. With less than ten supported directives
            it is easy to learn. In fact, most people are up and productive within
            less than a day.</p>
            </primary>
            <p>VTL はビューデザイナを意識したシンプルなテンプレートスクリプト言語として、
            最初から最後まで設計されました。
            サポートされている指示子は10未満であり、習得することが容易です。
            実際、ほとんどの人々は1日以内に習得して生産的になっています。</p>

            <primary>
            <p>Velocity does not allow Java scriptlets, which helps enforce a
            strict MVC separation.</p>
            </primary>
            <p>Velocity は Java のスクリプトレットを許容せず、
            明確な MVC の線引きを行います。</p>

            <primary>
            <p>Please consult the following two documents for an in-depth coverage
            of VTL:</p>
            </primary>
            <p>VTL の適用範囲の詳細については次の2つのドキュメントを調べてください:</p>

            <primary>
            <ul>
              <li><a href="http://jakarta.apache.org/velocity/user-guide.html">Velocity User's Guide</a></li>
              <li><a href="http://jakarta.apache.org/velocity/vtl-reference-guide.html">VTL Reference Guide</a></li>
            </ul>
            </primary>
            <ul>
              <li><a href="http://jakarta.apache.org/velocity/user-guide.html">Velocity ユーザガイド</a></li>
              <li><a href="http://jakarta.apache.org/velocity/vtl-reference-guide.html">VTL リファレンス</a></li>
            </ul>

            <br clear="all"/>

        </subsection>

        <subsection name="Exposing Data" alias="データを渡す">

            <primary>
            <p>The main purpose of Velocity in a web application is typically to
            merge HTML templates with dynamic application data to generate
            dynamic views. An essential aspect of Velocity is therefore the
            mechanism that allows the application controller (in MVC speak) to
            expose data to the template.</p>
            </primary>
            <p> Web アプリケーションにおいての Velocity の主要な目的は、
            動的なビューを生成するため、
            HTML テンプレートと動的なアプリケーションデータをマージすることです。
            Velocity の最も重要な点は、アプリケーションの
            (MVCでいうところの) コントローラが、
            アプリケーションデータをテンプレートへ渡すことを可能にするメカニズムなのです。</p>

            <primary>
            <p>It is important to understand the relationship between a
            Struts-based application and the Velocity template servlet. Both
            are simply Java Servlets which perform a specific task.</p>
            </primary>
            <p>Struts ベースのアプリケーションと
            Velocity テンプレートサーブレットの関係を理解することが重要です。
            両方とも、特定の処理を行うシンプルな Java サーブレットです。</p>

            <primary>
            <p> Requests to the Struts application are processed, application data
            is manipulated and eventually all data and control is forwarded to a
            View layer.</p>
            </primary>
            <p>Struts アプリケーションへのリクエストが処理され、
            アプリケーションデータが処理され、
            最終的には全てのデータと制御はビューレイヤにフォワードされます。</p>

            <primary>
            <p>The Velocity servlet in this case is responsible for merging the
            provided application data with a template to produce HTML output.</p>
            </primary>
            <p>このケースでは、 Velocity サーブレットは HTML 出力のために、
            渡されたアプリケーションとテンプレートをマージする役割を持ちます。</p>

            <primary>
            <p>We should note that the Velocity servlet is not exclusively tied
            to the Struts application. It can serve requests from web clients
            directly or any other servlet application as well. Technically, the
            Struts application hands over a request to Velocity through the
            <code>forward</code> method of <code>javax.servlet.RequestDispatcher</code>.
            </p>
            </primary>
            <p>Velocity サーブレットは Struts
            アプリケーションのみと関係しているわけではないことを覚えておいてください。
            Web クライアントからの直接のリクエストを受け付けることができますし、
            他のどんなサーブレットアプリケーションとも同様にできます。
            技術的なことを言うと、 Struts はリクエストを
            <code>javax.servlet.RequestDispatcher</code> の
            <code>forward</code> メソッドを用いて Velocity へ渡します。
            </p>

            <primary>
            <p>Application data is passed from the Struts servlet to the Velocity
            servlet as attributes of either the servlet request, session or context.</p>
            </primary>
            <p>アプリケーションデータは、サーブレットリクエスト、サーブレットセッション、
            サーブレットコンテキストのいずれかの属性として
            Struts サーブレットから Velocity サーブレットへ渡されます。</p>

            <primary>
            <p>Therefore a developer simply needs to set an attribute to pass data
            to the View layer and make that data available for the template. For example:
            </p>
            </primary>
            <p>したがって、開発者はビューレイヤにデータを渡すために属性を設定し、
            そのデータをテンプレートから利用できるようにする必要があります。
            例:
            </p>
            <primary>
            <p>
            <sourcecode>request.setAttribute("Customer", CustomerObj);</sourcecode>
            Whatever public methods are available on the CustomerObj instance will be
            made available to the template designer. Assuming there is a public
            getName() method, they may for example write: $Customer.name or
            $Customer.getName().
            </p>
            </primary>
            <p>
            <sourcecode>request.setAttribute("Customer", CustomerObj);</sourcecode>
            CustomerObj インスタンスの持つ全ての
            public メソッドがテンプレートデザイナへ提供され、
            利用することができます。
            public の getName() メソッドがあると仮定した場合、
            このように書くことができます:
            $Customer.name または $Customer.getName() 。
            </p>

            <primary>
            <p>There is a heirarchy to the objects exposed to the template designer.
            For instance, if you have set an attribute "foo" in both the session and 
            the request,</p>
            </primary>
            <p>テンプレートデザイナへ渡されるオブジェクトには優先順位があります。
            例えば、セッションとリクエスト両方に "foo" という属性があった場合、</p>
<sourcecode>request.setAttribute("foo", "request foo");
session.setAttribute("foo", "session foo");</sourcecode>
            <primary>
            <p>then the request attribute will take priority, and using </p>
            </primary>
            <p>リクエストの属性が優先され、テンプレート内で</p>
            <sourcecode>$foo</sourcecode>
            <primary>
            <p>in the template will give you</p>
            </primary>
            <p>を使用しますと次が得られます。</p>
<sourcecode>request foo</sourcecode>
            <primary>
            <p>Priority is given in the following order:
            <ol>
              <li>Tools specified in the toolbox.xml (e.g. $link, $tiles, etc.)</li>
              <li>The servlet classes (e.g. $request, $response, $session, $application)</li>
              <li>References set locally within the template</li>
              <li>Request attributes</li>
              <li>Session attributes</li>
              <li>Servlet context (application) attributes</li>
            </ol>
            </p>
            </primary>
            <p>優先順位は以下の順番で与えられます:
            <ol>
              <li>toolbox.xml にて指定されたツール(e.g. $link, $tiles, etc.)</li>
              <li>サーブレットのクラス (e.g. $request, $response, $session, $application)</li>
              <li>テンプレート内でローカルにセットされたリファレンス</li>
              <li>リクエストの属性</li>
              <li>セッションの属性</li>
              <li>サーブレットコンテキスト (application) の属性</li>
            </ol>
            </p>
            <primary>
            <p>This heirarchy allows the developer to reserve control of key references
            (for tools and servlet resources) from the template designer and allows for
            values to be set at various servlet scopes in a manner similar to working
            with JSP and Struts.</p>
            </primary>
            <p>この優先順位によって開発者はテンプレートデザイナから重要なリファレンス
            (ツールやサーブレットリソース) の制御を確保できます。
            また、JSP と Struts で開発するのと同じように、
            サーブレットのさまざまなスコープに値をセットできるようになります。</p>

            <br clear="all"/>
        </subsection>

        <subsection name="Access to Servlet Resources" alias="サーブレットリソースへのアクセス">

            <primary>
            <p>VelocityStruts automatically populates the context with the following
            objects of the Servlet API on each template processing request:</p>
            </primary>
            <p>VelocityStruts は、各テンプレート処理リクエストごとに、自動的に Servlet API
            の以下のオブジェクトをコンテキストを設定します:</p>

            <primary>
            <table>
              <tr>
                <th>Context Key</th>
                <th>Class</th>
                <th>Remarks</th>
              </tr>
              <tr>
                <td>$request</td>
                <td>javax.servlet.http.HttpServletRequest</td>
                <td>the current servlet request</td>
              </tr>
              <tr>
                <td>$session</td>
                <td>javax.servlet.http.HttpSession</td>
                <td>the current session, if one exists</td>
              </tr>
              <tr>
                <td>$application</td>
                <td>javax.servlet.ServletContext</td>
                <td>the servlet context</td>
              </tr>
              <tr>
                <td>$response</td>
                <td>javax.servlet.http.HttpServletResponse</td>
                <td>the current servlet response</td>
              </tr>
            </table>
            </primary>
            <table>
              <tr>
                <th>コンテキストキー</th>
                <th>クラス</th>
                <th>備考</th>
              </tr>
              <tr>
                <td>$request</td>
                <td>javax.servlet.http.HttpServletRequest</td>
                <td>処理中のサーブレットリクエスト</td>
              </tr>
              <tr>
                <td>$session</td>
                <td>javax.servlet.http.HttpSession</td>
                <td>もし存在する場合、処理中のセッション</td>
              </tr>
              <tr>
                <td>$application</td>
                <td>javax.servlet.ServletContext</td>
                <td>サーブレットコンテキスト</td>
              </tr>
              <tr>
                <td>$response</td>
                <td>javax.servlet.http.HttpServletResponse</td>
                <td>処理中のサーブレットレスポンス</td>
              </tr>
            </table>

            <br clear="all"/>

            <primary>
            <p>The following examples illustrates how servlet resources are
            accessed from within Velocity template. The example renders
            the list of HTTP header fields of the current servlet request.
            In the same way, any public method of the above listed objects can
            be called from within templates:</p>
            </primary>
            <p>以下の例では、サーブレットのリソースが
            Velocity テンプレートからどのようにアクセスされるかを示します。
            この例は、処理中のサーブレットリクエストの
            HTTP ヘッダーのフィールドのリストを表示します。
            同じ方法で、上記にリストされているオブジェクトのどんな
            public メソッドでもテンプレートの内部から呼ぶことができます:</p>

<sourcecode>#foreach( $header in $request.HeaderNames )
  &lt;b&gt;$header:&lt;/b&gt; $request.getHeader($header)&lt;br&gt;
#end</sourcecode>

            <primary>
            <p>The resulting output is something like this:</p>
            </primary>
            <p>出力結果はこのようになります:</p>

<sourcecode><b>Referer:</b> http://localhost:8080/struts/doc/examples.html
<b>Connection:</b> Keep-Alive
<b>User-Agent:</b> Mozilla/4.79 [en] (Windows NT 5.0; U)
<b>Pragma:</b> no-cache
<b>Host:</b> localhost:8080
<b>Accept:</b> image/gif, image/jpeg, image/pjpeg, image/png, */*
<b>Accept-Encoding:</b> gzip
<b>Accept-Language:</b> en
<b>Accept-Charset:</b> iso-8859-1,*,utf-8
<b>Cookie:</b> JSESSIONID=aaaecXd7bnLPAr
</sourcecode>

            <br clear="all"/>

        </subsection>

        <subsection name="Access to Struts Framework Resources" alias="Strutsフレームワークリソースへのアクセス">

            <primary>
            <p>The Struts framework provides resources that
            are useful to template designers. These include logical names for
            physical resources, internationalized messages, error handling,
            form handling, etc. The interesting question is now how template
            designers can gain access these framework resources. In the JSP world, a set
            of custom tag libraries provide template
            designers access to the Struts framework resources. In the Velocity
            world, the equivalent of the JSP custom tag libraries are <b>view
            tools</b>. View tools are a very simple concept. They are Java objects
            with public methods that are put into the Velocity context. Tools are
            accessed by key and allows template designers to call on their public methods.</p>
            </primary>
            <p>Struts フレームワークは、
            テンプレートデザイナにとって役立つリソースを提供します。
            これらは、物理的なリソースの論理名、国際化されたメッセージ、
            エラーハンドリング、フォームハンドリングなどを含んでいます。
            気になるところとしては、
            テンプレートデザイナがどのようにフレームワークのリソースへアクセスすることができるかでしょう。
            JSP では、一連のカスタムタグライブラリが、テンプレートデザイナに
            Struts フレームワークのリソースへのアクセスを提供します。
            Velocity では、 JSP カスタムタグライブラリと等価なものとして
            <b>ビューツール</b>があります。
            ビューツールは非常にシンプルなものです。
            それらは Velocity コンテキストの中に格納される、
            public メソッドを持つ Java オブジェクトです。
            ツールはキーによってアクセスされ、
            テンプレートデザイナはそれらの
            public メソッドを呼び出すことができます。</p>

            <primary>
            <p>A set of seven view tools is included with VelocityStruts
            that provide template designers access to Struts framework resources.
            These seven view tools essentially achieve the integration between
            Struts and Velocity and they can be considered the core of this
            project.</p>
            </primary>
            <p>テンプレートデザイナーに
            Struts フレームワークのリソースへのアクセスを提供する
            7つのビューツールが VelocityStruts には含まれています。
            これらの7つのビューツールは、
            Struts と Velocity 間の統合を実現する、
            このプロジェクトのコアとなる部分です。</p>

            <primary>
            <table>
              <tr>
                <th>Context Key</th>
                <th>Class</th>
                <th>Remarks</th>
              </tr>
              <tr>
                <td>$text</td>
                <td><a href="MessageTool.html">MessageTool</a></td>
                <td>Provides access to the Struts application resources for internationalized text.</td>
              </tr>
              <tr>
                <td>$errors</td>
                <td><a href="ErrorsTool.html">ErrorsTool</a></td>
                <td>Provides methods to check for and output Struts error messages.</td>
              </tr>
              <tr>
                <td>$messages</td>
                <td><a href="ActionMessagesTool.html">ActionMessagesTool</a></td>
                <td>Provides methods to work with Struts action messages.</td>
              </tr>
              <tr>
                <td>$link</td>
                <td><a href="StrutsLinkTool.html">StrutsLinkTool</a></td>
                <td>Provides methods to work with URIs.</td>
              </tr>
              <tr>
                <td>$form</td>
                <td><a href="FormTool.html">FormTool</a></td>
                <td>Provides miscellaneous methods to work with forms and form
                beans in the context of Struts applications.</td>
              </tr>
              <tr>
                <td>$tiles</td>
                <td><a href="TilesTool.html">TilesTool</a></td>
                <td>Provides miscellaneous methods to work with Tiles in the
                context of Struts applications.</td>
              </tr>
              <tr>
                <td>$validator</td>
                <td><a href="ValidatorTool.html">ValidatorTool</a></td>
                <td>Provides methods to dynamically generate javascript validation
                in the context of Struts applications.</td>
              </tr>
              <tr>
                <td colspan="3">Note: The shown keys are the recommended values.
                They can be changed in the configuration.</td>
              </tr>
            </table>
            </primary>
            <table>
              <tr>
                <th>コンテキストキー</th>
                <th>クラス</th>
                <th>備考</th>
              </tr>
              <tr>
                <td>$text</td>
                <td><a href="MessageTool.html">MessageTool</a></td>
                <td>国際化されたテキストのための Struts のアプリケーションリソースへのアクセスを提供します。</td>
              </tr>
              <tr>
                <td>$errors</td>
                <td><a href="ErrorsTool.html">ErrorsTool</a></td>
                <td>Struts のエラーメッセージをチェックし、出力するためのメソッドを提供します。</td>
              </tr>
              <tr>
                <td>$messages</td>
                <td><a href="ActionMessagesTool.html">ActionMessagesTool</a></td>
                <td>Struts のアクションメッセージに関するメソッドを提供します。</td>
              </tr>
              <tr>
                <td>$link</td>
                <td><a href="StrutsLinkTool.html">StrutsLinkTool</a></td>
                <td>URIに関するメソッドを提供します。</td>
              </tr>
              <tr>
                <td>$form</td>
                <td><a href="FormTool.html">FormTool</a></td>
                <td>フォームや、Struts
                アプリケーションのコンテキスト内のフォームビーンに関するさまざまなメソッドを提供します。</td>
              </tr>
              <tr>
                <td>$tiles</td>
                <td><a href="TilesTool.html">TilesTool</a></td>
                <td>Struts アプリケーションのコンテキスト内でTiles
                に関するさまざまなメソッドを提供します。</td>
              </tr>
              <tr>
                <td>$validator</td>
                <td><a href="ValidatorTool.html">ValidatorTool</a></td>
                <td>Struts アプリケーションのコンテキスト内で動的にjavascript
                によるバリデーションを生成するメソッドを提供します。</td>
              </tr>
              <tr>
                <td colspan="3">注意: ここにあるキーは推奨されている値です。
                設定で変更することができます。</td>
              </tr>
            </table>

            <primary>
            <p>The following example illustrates some of the features of the MessageTool
            for working with internationalized messages. For the example we assume that
            the Struts message resources contain the following two key=value pairs:</p>
            </primary>
            <p>以下の例は、国際化メッセージに関する処理を行う
            MessageTool のいくつかの機能を示しています。
            例では、 Struts のメッセージリソースに以下の
            key=value のペアを含んでいると仮定します:</p>
            <primary>
<sourcecode>
title=Struts Example Application
test=This string has 4 replacement parameters: {1}, {2}, {3}, {4}
</sourcecode>
            </primary>
<sourcecode>
title=Struts Example Application
test=This string has 4 replacement parameters: {1}, {2}, {3}, {4}
</sourcecode>

            <primary>
<p>Then, the following script...</p>
            </primary>
<p>以下のスクリプト...</p>

<sourcecode>
$text.get("title")
$text.get("test", ["bear", "dog", "cat"])
$text.exists("tutle")
$text.getLocale()
</sourcecode>

            <primary>
<p>..will produce this output:</p>
            </primary>
<p>..はこの出力を生成します:</p>

            <primary>
<sourcecode>
Struts Example Application
This string has 4 replacement parameters: bear, dog, cat, {4}
false
en
</sourcecode>
            </primary>
<sourcecode>
Struts Example Application
This string has 4 replacement parameters: bear, dog, cat, {4}
false
en
</sourcecode>

            <primary>
            <p>Please see the <a href="StrutsTools.html">Tool Reference Documentation</a>
            for more details about the view tools. Furthermore, the Velocity/Struts
            <a href="index.html#Download">example application</a> comes with several
            working examples that show how these tools are used.</p>
            </primary>
            <p>ビューツールに関する詳細は、
            <a href="StrutsTools.html">ツールリファレンスドキュメント</a>
            を参照してください。
            また、 Velocity/Struts
            <a href="index.html#Download">サンプルアプリケーション</a> には、
            これらのツールがどのように使用されるかを示す、
            いくつかの例が付属しています。</p>

            <br clear="all"/>

        </subsection>

        <br clear="all"/>

    </section>

 </body>
</document>

