<?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: ErrorsTool.xml,v 1.6 2005/03/20 19:59:48 nekop Exp $
-->
<document>

    <properties>
        <title>ErrorsTool</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="nekop@programmers.jp">木村 貴由</translator>
        <original>ErrorsTool</original>
   </properties>

    <body>

    <section name="ErrorsTool Reference Documentation" alias="ErrorsTool リファレンスドキュメント">

        <primary>
        <p>
        This tool deals with Struts error messages. Errors may stem from the validation
        of a submitted form or from the processing of a request. If there are errors,
        they are made available to the view to render. A few important aspects about errors
        are:</p>
        <ul>
            <li>Error message strings are looked up in the message resources. Support
                for internationalized messages is provided.</li>
            <li>Error messages can have up to five replacement parameters.</li>
            <li>Errors have an attribute <code>property</code> that describes the category of
                error. This allows the view designer to place error messages precisely where an
                error occurred. For example, errors that apply to the entire page can be rendered
                at the top of the page, errors that apply to a specific input field can be rendered
                next to this input field. Several methods of this tool provide a parameter
                <code>property</code> that allows to select a specific category of errors to operate
                on. Without the <code>property</code> parameter, methods operate on all error messages.</li>
        </ul>
        </primary>
        <p>
        このツールは Struts のエラーメッセージを提供します。
        エラーはサブミットされたフォームの検証中、あるいはリクエストの処理中に発生します。
        エラーが起きた場合、ビューへの出力を生成できるようになります。
        エラーについて抑えておくべき重要な点は:</p>
        <ul>
            <li>エラーメッセージはメッセージリソースから取得されます。
                国際化されたメッセージの提供がサポートされています。</li>
            <li>エラーメッセージは置換パラメータを5つまで持つことができます。</li>
            <li>エラーはエラーカテゴリを示す <code>property</code> 属性を持ちます。
                これはビューデザイナがエラーが発生した場所に適切にエラーメッセージを配置することを可能にします。
                例えば、ページの全体に対してのエラーはページの一番上に表示し、
                特定の入力フィールドに対してのエラーはこの入力フィールドの隣りに表示することができます。
                このツールのいくつかのメソッドは、処理対象とする特定のエラーカテゴリを選択できる <code>property</code> パラメータを提供します。
                <code>property</code> パラメータを指定しない場合、これらのメソッドは全てのエラーメッセージを処理します。</li>
        </ul>

        <primary>
        <p>See the Struts User's Guide, section
        <a href="http://jakarta.apache.org/struts/userGuide/building_view.html">Building View Components</a>
        for more information on this topic.</p>
        </primary>
        <p>この話題のより詳細については Struts ユーザガイドの
        <a href="http://jakarta.apache.org/struts/userGuide/building_view.html">Building View Components</a>
        の章を参照してください。</p>

        <toolinfo>
            <version>@@@version@@@, @@@date@@@</version>
            <clazz>org.apache.velocity.tools.struts.ErrorsTool</clazz>
            <name>$errors</name>
            <author email="sidler@teamup.com">Gabriel Sidler</author>
            <config-example>&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;</config-example>
        </toolinfo>

        <methods/>

    </section>

    <section name="exist()">
        <primary>
        <method name="exist()">

            <abstract>
                Returns <code>true</code> if there are errors queued, otherwise <code>false</code>.
            </abstract>

            <signature>
                boolean exist()
            </signature>

            <signature>
                boolean exist(String property)
            </signature>

            <parameters>
                <parameter name="property">
                    The category of errors to check for.
                </parameter>
            </parameters>

            <returns>
                <code>true</code> if there are error messages queued. <code>false</code> otherwise.
            </returns>

            <description>
                <p>Calling <code>exist()</code> without the <code>property</code> parameter checks for error messages of
                any category. The <code>property</code> parameter can be used to limit the check to
                error messages of a specific category.</p>

<sourcecode>$errors.exist()
$errors.exist("password")
</sourcecode>
            </description>

        </method>
        </primary>
        <method name="exist()">

            <abstract>
                エラーメッセージがある場合に<code>true</code>を返却、その他の場合<code>false</code>。
            </abstract>

            <signature>
                boolean exist()
            </signature>

            <signature>
                boolean exist(String property)
            </signature>

            <parameters>
                <parameter name="property">
                    チェックするエラーのカテゴリ。
                </parameter>
            </parameters>

            <returns>
                エラーメッセージがある場合に<code>true</code>を返却、その他の場合<code>false</code>。
            </returns>

            <description>
                <p><code>property</code> パラメータを指定せずに <code>exist()</code> を呼び出すと全てのカテゴリのエラーメッセージがチェックされます。
                <code>property</code> パラメータは特定カテゴリのエラーメッセージのチェックに使用します。</p>

<sourcecode>$errors.exist()
$errors.exist("password")
</sourcecode>
            </description>

        </method>
    </section>

    <section name="getSize()">
        <primary>
        <method name="getSize()">

            <abstract>
                Returns the number of error messages queued.
            </abstract>

            <signature>
                int getSize()
            </signature>

            <signature>
                int getSize(String property)
            </signature>

            <parameters>
                <parameter name="property">
                    The category of errors to operate on.
                </parameter>
            </parameters>

            <returns>
                The number of error messages.
            </returns>

            <description>
                <p>Calling <code>getSize()</code> without the <code>property</code> parameter returns the total
                number of queued error messages. The <code>property</code> parameter can be used to
                obtain the number of queued error messages for a specific category.</p>

<sourcecode>$errors.getSize()
$errors.size
$errors.getSize("password")</sourcecode>
            </description>

        </method>
        </primary>
        <method name="getSize()">

            <abstract>
                エラーメッセージの数を返却します。
            </abstract>

            <signature>
                int getSize()
            </signature>

            <signature>
                int getSize(String property)
            </signature>

            <parameters>
                <parameter name="property">
                    対象とするエラーのカテゴリ。
                </parameter>
            </parameters>

            <returns>
                エラーメッセージの数を返却します。
            </returns>

            <description>
                <p><code>property</code> パラメータを指定せずに <code>getSize()</code> を呼び出すと全てのカテゴリのエラーメッセージの総数を返却します。
                <code>property</code> パラメータは特定カテゴリのエラーメッセージの数を取得するときに使用します。</p>

<sourcecode>$errors.getSize()
$errors.size
$errors.getSize("password")</sourcecode>
            </description>

        </method>
    </section>

    <section name="getGlobal()">
        <primary>
        <method name="getGlobal()">

            <abstract>
                This a convenience method and the equivalent of
                <code>$errors.get($errors.globalName)</code>
            </abstract>

            <signature>
                List getGlobal()
            </signature>

            <returns>
                A list of all errors stored under the "global" property.
            </returns>

            <description>
                <p>See the section on get() for more information.</p>
            </description>
        </method>
        </primary>
        <method name="getGlobal()">

            <abstract>
                これは<code>$errors.get($errors.globalName)</code>と同等の簡易メソッドです。
            </abstract>

            <signature>
                List getGlobal()
            </signature>

            <returns>
                "global"プロパティの全てのエラーのリスト
            </returns>

            <description>
                <p>より詳細についてはget()セクションを参照してください。</p>
            </description>
        </method>
    </section>

    <section name="getAll()">
        <primary>
        <method name="getAll()">

            <abstract>
                Returns a list of localized error messages for all errors queued.
            </abstract>

            <signature>
                List getAll()
            </signature>

            <signature>
                List getAll(String bundle)
            </signature>

            <parameters>
                <parameter name="bundle">
                    The (non-default) message-resources bundle that holds the error messages.
                </parameter>
            </parameters>

            <returns>
                If the message resources are lacking an error message for a
                particular message key, the key itself is used as an error message
                and a warning is logged.
            </returns>

            <description>
                <p>The following example shows a macro to render the error messages:</p>

<sourcecode>&#35;macro (errorMarkup)
    &#35;if (&#36;errors.exist)
        &lt;ul&gt;
        &#35;foreach (&#36;e in &#36;errors.all )
            &lt;li&gt;&#36;e&lt;/li&gt;
        &#35;end
        &lt;/ul&gt;
    &#35;end
&#35;end</sourcecode>

<p>This produces output similar to the following:</p>

<sourcecode>&lt;ul&gt;
    &lt;li&gt;The field Expiration Date is required.&lt;/li&gt;
    &lt;li&gt;The provided number is not a valid credit card number&lt;/li&gt;
&lt;/ul&gt;</sourcecode>
            </description>

        </method>
        </primary>
        <method name="getAll()">

            <abstract>
                全てのメッセージについての地域化されたエラーメッセージのリストを返却します。
            </abstract>

            <signature>
                List getAll()
            </signature>

            <signature>
                List getAll(String bundle)
            </signature>

            <parameters>
                <parameter name="bundle">
                    エラーメッセージを保持する(デフォルトではない)メッセージリソースバンドル。
                </parameter>
            </parameters>

            <returns>
                特定のメッセージキーのエラーメッセージがメッセージリソースに無かった場合、
                そのキー自体がエラーメッセージとして使用され、このとき警告がロギングされます。
            </returns>

            <description>
                <p>以下の例はエラーメッセージを表示するマクロです:</p>

<sourcecode>&#35;macro (errorMarkup)
    &#35;if (&#36;errors.exist)
        &lt;ul&gt;
        &#35;foreach (&#36;e in &#36;errors.all )
            &lt;li&gt;&#36;e&lt;/li&gt;
        &#35;end
        &lt;/ul&gt;
    &#35;end
&#35;end</sourcecode>

<p>これは以下のような出力を生成します:</p>

<sourcecode>&lt;ul&gt;
    &lt;li&gt;フィールドExpiration Dateは必須です。&lt;/li&gt;
    &lt;li&gt;入力された番号は有効なクレジットカード番号ではありません。&lt;/li&gt;
&lt;/ul&gt;</sourcecode>
            </description>

        </method>
    </section>


    <section name="get()">
        <primary>
        <method name="get()">

            <abstract>
                Returns a list of localized error messages for a particular category
                of errors.
            </abstract>

            <signature>
                List get(String property)
            </signature>

            <signature>
                List get(String property, String bundle)
            </signature>

            <parameters>
                <parameter name="property">
                    The category of error messages to return.
                </parameter>

                <parameter name="bundle">
                    The (non-default) message-resources bundle that holds the error messages.
                </parameter>
            </parameters>

            <returns>
                A <code>java.util.List</code> of <code>java.lang.String</code>.
                If no error messages exist for the specified category,
                <code>null</code> is returned.
                If the message resources are lacking an error message for a
                particular message key, the key itself is used as an error message
                and a warning is logged.
            </returns>

            <description>
                <p>The following example shows a macro to render the error messages for a
                particular category of errors:</p>

<sourcecode>&#35;macro (errorMarkup &#36;property)
    &#35;if (&#36;errors.exist(&#36;property))
        &lt;ul&gt;
        &#35;foreach (&#36;er in &#36;errors.get(&#36;property) )
            &lt;li&gt;&#36;er&lt;/li&gt;
        &#35;end
        &lt;/ul&gt;
    &#35;end
&#35;end</sourcecode>

<p>This produces output similar to the following:</p>

<sourcecode>&lt;ul&gt;
    &lt;li&gt;The field Expiration Date is required.&lt;/li&gt;
    &lt;li&gt;The provided number is not a valid credit card number&lt;/li&gt;
&lt;/ul&gt;</sourcecode>
            </description>

        </method>
        </primary>
        <method name="get()">

            <abstract>
                指定されたカテゴリのエラーについての地域化されたエラーメッセージのリストを返却します。
            </abstract>

            <signature>
                List get(String property)
            </signature>

            <signature>
                List get(String property, String bundle)
            </signature>

            <parameters>
                <parameter name="property">
                    返却するエラーメッセージのカテゴリ。
                </parameter>

                <parameter name="bundle">
                    エラーメッセージを保持する(デフォルトではない)エラーリソースバンドル。
                </parameter>
            </parameters>

            <returns>
                <code>java.lang.String</code> の <code>java.util.List</code> 。
                指定されたカテゴリにエラーメッセージが無い場合には、
                <code>null</code> を返却します。
                特定のメッセージキーのエラーメッセージがメッセージリソースに無かった場合、
                そのキー自体がエラーメッセージとして使用され、このとき警告がロギングされます。
            </returns>

            <description>
                <p>以下の例は特定のエラーカテゴリのエラーメッセージを表示するマクロです:</p>

<sourcecode>&#35;macro (errorMarkup &#36;property)
    &#35;if (&#36;errors.exist(&#36;property))
        &lt;ul&gt;
        &#35;foreach (&#36;er in &#36;errors.get(&#36;property) )
            &lt;li&gt;&#36;er&lt;/li&gt;
        &#35;end
        &lt;/ul&gt;
    &#35;end
&#35;end</sourcecode>

<p>これは以下のような出力を生成します:</p>

<sourcecode>&lt;ul&gt;
    &lt;li&gt;フィールドExpiration Dateは必須です。&lt;/li&gt;
    &lt;li&gt;入力された番号は有効なクレジットカード番号ではありません。&lt;/li&gt;
&lt;/ul&gt;</sourcecode>
            </description>

        </method>
    </section>


    <section name="getMsgs()">
        <primary>
        <method name="getMsgs()">

            <abstract>
                Renders the queued errors messages.
            </abstract>

            <signature>
                String getMsgs()
            </signature>

            <signature>
                String getMsgs(String property)
            </signature>

            <signature>
                String getMsgs(String property, String bundle)
            </signature>

            <parameters>
                <parameter name="property">
                    The category of errors messages to render.
                </parameter>

                <parameter name="bundle">
                    The (non-default) message-resources bundle that holds the error messages.
                </parameter>
            </parameters>

            <returns>
                The formatted error messages. If no errors are queued, an
                empty <code>String</code> is returned.
            </returns>

            <description>
                <p>This method renders the queued error messages as a list. If the method
                is called without a parameter, all queued errors are rendered. With the
                parameter <code>property</code> the list of rendered messages can be
                limited to a specific category of errors. Error message texts
                are looked up in the message resources. If a message text
                cannot be found, the message key will be displayed instead.</p>

                <p>The method expects a message header and a message footer
                to be defined in the message resources. The corresponding
                message keys are <code>errors.header</code> and
                <code>errors.footer</code>.</p>

                <p>Assuming that the message resources contain the following
                definitions:</p>

<sourcecode>errors.header=Please correct the following errors:&lt;ul&gt;
errors.footer=&lt;/ul&gt;
error01=&lt;li&gt;The field Expiration Date is required.&lt;/li&gt;
error02=&lt;li&gt;The input is not a valid credit card number.&lt;/li&gt;
...</sourcecode>

<p>an error message would be rendered as follows:</p>

<sourcecode>Please correct the following errors before proceeding:&lt;ul&gt;
    &lt;li&gt;The field Expiration Date is required.&lt;/li&gt;
    &lt;li&gt;The input is not a valid credit card number.&lt;/li&gt;
&lt;/ul&gt;</sourcecode>
            </description>

        </method>
        </primary>
        <method name="getMsgs()">

            <abstract>
                エラーメッセージを表示します。
            </abstract>

            <signature>
                String getMsgs()
            </signature>

            <signature>
                String getMsgs(String property)
            </signature>

            <signature>
                String getMsgs(String property, String bundle)
            </signature>

            <parameters>
                <parameter name="property">
                    表示するエラーメッセージのカテゴリ。
                </parameter>

                <parameter name="bundle">
                    エラーメッセージを保持する(デフォルトではない)メッセージリソースバンドル。
                </parameter>
            </parameters>

            <returns>
                フォーマットされたエラーメッセージ。
                エラーが無い場合、空の <code>String</code> が返却されます。
            </returns>

            <description>
                <p>このメソッドはエラーメッセージをリストとして表示します。
                パラメータ無しで呼び出した場合、全てのエラーが表示されます。
                <code>property</code> パラメータを指定した場合、特定のカテゴリのエラーのメッセージリストを表示します。
                エラーメッセージの文字列はメッセージリソースから取得されます。
                メッセージが見つからなかった場合、メッセージのキーを代わりに表示します。</p>

                <p>このメソッドはメッセージヘッダとメッセージフッタがメッセージリソースに定義されていることを前提とします。
                これらのメッセージのキーは <code>errors.header</code> と
                <code>errors.footer</code> です。</p>

                <p>メッセージリソースが以下のように定義されている場合:</p>

<sourcecode>errors.header=以下のエラーを修正して下さい:&lt;ul&gt;
errors.footer=&lt;/ul&gt;
error01=&lt;li&gt;フィールドExpiration Dateは必須です。&lt;/li&gt;
error02=&lt;li&gt;入力された番号は有効なクレジットカード番号ではありません。&lt;/li&gt;
...</sourcecode>

<p>エラーメッセージは以下のように表示されます:</p>

<sourcecode>以下のエラーを修正して下さい:&lt;ul&gt;
    &lt;li&gt;フィールドExpiration Dateは必須です。&lt;/li&gt;
    &lt;li&gt;入力された番号は有効なクレジットカード番号ではありません。&lt;/li&gt;
&lt;/ul&gt;</sourcecode>
            </description>

        </method>
    </section>


 </body>
</document>

