|
Velocity Tools
VelocityStruts
VelocityStruts Tools
その他のサブプロジェクト
|
|
ActionMessagesTool リファレンスドキュメント
|
| |
This tool deals with Struts action messages. A few important aspects about action
messages are:
- Action message strings are looked up in the message resources. Support
for internationalized messages is provided.
- Action messages can have up to five replacement parameters.
- Actions have an attribute
property that describes the category of
message. This allows the view designer to place action messages precisely where they are
wanted. Several methods of this tool provide a parameter
property that allows to select a specific category of messages to operate
on. Without the property parameter, methods operate on all action messages.
このツールは Struts のアクションメッセージを提供します。
アクションメッセージについて抑えておくべき重要な点は:
- アクションメッセージはメッセージリソースから取得されます。
国際化されたメッセージの提供がサポートされています。
- アクションメッセージは置換パラメータを5つまで持つことができます。
- アクションはメッセージカテゴリを示す
property 属性を持ちます。
これはビューデザイナが適切な場所にアクションメッセージを配置することを可能にします。
このツールのいくつかのメソッドは、処理対象とする特定のメッセージカテゴリを選択できる property パラメータを提供します。
property パラメータを指定しない場合、これらのメソッドは全てのアクションメッセージを処理します。
See the Struts User's Guide, section
Building View Components
for more information on this topic.
この話題のより詳細については Struts ユーザガイドの
Building View Components
の章を参照してください。
| Class |
| | org.apache.velocity.tools.struts.ActionMessagesTool |
| Name |
| | $messages (Velocityコンテキスト内での推奨名) |
| Toolbox設定例 |
| | <tool>
<key>messages</key>
<scope>request</scope>
<class>org.apache.velocity.tools.struts.ActionMessagesTool</class>
</tool> |
| 作者 |
| | Gabriel Sidler Nathan Bubna
|
- Method Overview
-
|
exist() |
Returns true if there are action messages queued,
otherwise false.
|
|
getSize() |
Returns the number of action messages queued.
|
|
getGlobal() |
This a convenience method and the equivalent of
$messages.get($messages.globalName)
|
|
getAll() |
Returns a list of localized action messages for all action messages queued.
|
|
get() |
Returns a list of localized action messages for a particular category
of action messages.
|
- Method Overview
-
|
exist() |
アクションメッセージがある場合にtrueを返却、その他の場合false。
|
|
getSize() |
アクションメッセージの数を返却します。
|
|
getGlobal() |
これは$messages.get($messages.globalName)と同等の簡易メソッドです。
|
|
getAll() |
全てのメッセージについての地域化されたアクションメッセージのリストを返却します。
|
|
get() |
指定されたカテゴリのメッセージについての地域化されたアクションメッセージのリストを返却します。
|
|
|
exist()
|
| |
Returns true if there are action messages queued,
otherwise false.
boolean exist(String property)
|
- Parameters
-
- property
-
The category of messages to check for.
- Returns
-
true if there are action messages queued. false otherwise.
Calling exist() without the property parameter checks for action messages of
any category. The property parameter can be used to limit the check to
action messages of a specific category.
$errors.exist()
$errors.exist("password")
|
|
アクションメッセージがある場合にtrueを返却、その他の場合false。
boolean exist(String property)
|
- Parameters
-
- property
-
チェックするメッセージのカテゴリ。
- Returns
-
アクションメッセージがある場合に
trueを返却、その他の場合false。
property パラメータを指定せずに exist() を呼び出すと全てのカテゴリのアクションメッセージがチェックされます。
property パラメータは特定カテゴリのアクションメッセージのチェックに使用します。
$errors.exist()
$errors.exist("password")
|
|
|
|
getSize()
|
| |
Returns the number of action messages queued.
int getSize(String property)
|
- Parameters
-
- property
-
The category of action messages to operate on.
- Returns
-
The number of action messages.
Calling getSize() without the property parameter returns the total
number of queued action messages. The property parameter can be used to
obtain the number of queued action messages for a specific category.
$messages.getSize()
$messages.size
$messages.getSize("password")
|
|
アクションメッセージの数を返却します。
int getSize(String property)
|
- Parameters
-
- property
-
チェックするメッセージのカテゴリ。
- Returns
-
アクションメッセージの数を返却します。
property パラメータを指定せずに getSize() を呼び出すと全てのカテゴリのアクションメッセージの総数を返却します。
property パラメータは特定カテゴリのアクションメッセージの数を取得するときに使用します。
$messages.getSize()
$messages.size
$messages.getSize("password")
|
|
|
|
getGlobal()
|
| |
This a convenience method and the equivalent of
$messages.get($messages.globalName)
- Returns
-
A list of all messages stored under the "global" property.
See the section on get() for more information.
これは$messages.get($messages.globalName)と同等の簡易メソッドです。
- Returns
-
"global"プロパティの全てのメッセージのリスト
より詳細についてはget()セクションを参照してください。
|
|
getAll()
|
| |
Returns a list of localized action messages for all action messages queued.
List getAll(String bundle)
|
- Parameters
-
- bundle
-
The (non-default) message-resources bundle that holds the action messages.
- Returns
-
If the message resources are lacking an action message message for a
particular message key, the key itself is used as an action message
and a warning is logged.
The following example shows a macro to render the action messages:
#macro (messagesMarkup)
#if ($messages.exist)
<ul>
#foreach ($e in $messages.all )
<li>$e</li>
#end
</ul>
#end
#end
|
|
This produces output similar to the following:
<ul>
<li>This is the first action message in the queue.</li>
<li>This is the second action message in the queue.</li>
</ul>
|
|
全てのメッセージについての地域化されたアクションメッセージのリストを返却します。
List getAll(String bundle)
|
- Parameters
-
- bundle
-
アクションメッセージを保持する(デフォルトではない)メッセージリソースバンドル。
- Returns
-
特定のメッセージキーのアクションメッセージがメッセージリソースに無かった場合、
そのキー自体がアクションメッセージとして使用され、このとき警告がロギングされます。
以下の例はアクションメッセージを表示するマクロです:
#macro (messagesMarkup)
#if ($messages.exist)
<ul>
#foreach ($e in $messages.all )
<li>$e</li>
#end
</ul>
#end
#end
|
|
これは以下のような出力を生成します:
<ul>
<li>これは最初のアクションメッセージです。</li>
<li>これは二番目のアクションメッセージです。</li>
</ul>
|
|
|
|
get()
|
| |
Returns a list of localized action messages for a particular category
of action messages.
List get(String property)
|
List get(String property, String bundle)
|
- Parameters
-
- property
-
The category of action messages to return.
- bundle
-
The (non-default) message-resources bundle that holds the action messages.
- Returns
-
A
java.util.List of java.lang.String.
If no action messages exist for the specified category,
null is returned.
If the message resources are lacking an error message for a
particular message key, the key itself is used as an action message
and a warning is logged.
The following example shows a macro to render the action messages for a
particular category of action messages:
#macro (messagesMarkup $property)
#if ($messages.exist($property))
<ul>
#foreach ($er in $messages.get($property) )
<li>$er</li>
#end
</ul>
#end
#end
|
|
This produces output similar to the following:
<ul>
<li>This is the first action message in the queue.</li>
<li>TThis is the second action message in the queue.</li>
</ul>
|
|
指定されたカテゴリのメッセージについての地域化されたアクションメッセージのリストを返却します。
List get(String property)
|
List get(String property, String bundle)
|
- Parameters
-
- property
-
返却するメッセージのカテゴリ。
- bundle
-
アクションメッセージを保持する(デフォルトではない)メッセージリソースバンドル。
- Returns
-
java.lang.String の java.util.ArrayList 。
指定されたカテゴリにアクションメッセージが無い場合には、
null を返却します。
特定のメッセージキーのアクションメッセージがメッセージリソースに無かった場合、
そのキー自体がアクションメッセージとして使用され、このとき警告がロギングされます。
以下の例は特定のメッセージカテゴリのアクションメッセージを表示するマクロです:
#macro (messagesMarkup $property)
#if ($messages.exist($property))
<ul>
#foreach ($er in $messages.get($property) )
<li>$er</li>
#end
</ul>
#end
#end
|
|
これは以下のような出力を生成します:
<ul>
<li>これは最初のアクションメッセージです。</li>
<li>これは二番目のアクションメッセージです。</li>
</ul>
|
|
|
|