The Jakarta Project < Velocity Tools - Struts >

Velocity Tools

VelocityStruts

VelocityStruts Tools

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

TilesTool リファレンスドキュメント
       

The TilesTool is used to interact with the Tiles framework that is now part of Struts (since v. 1.1).

TilesToolはTilesフレームワークと連携するために使用されます。 Tilesフレームワークはv. 1.1よりStrutsの一部となりました。

Class
 org.apache.velocity.tools.struts.TilesTool
Name
 $tiles (Velocityコンテキスト内での推奨名)
Toolbox設定例
 
<tool>
  <key>tiles</key>
  <scope>request</scope>
  <class>org.apache.velocity.tools.struts.TilesTool</class>
</tool>
作者
 Marino A. Jonsson
Method Overview
importAttributes() Imports all attributes in the current tiles definition into the named context
getAttribute() Returns a named tiles attribute from the current tiles definition
importAttribute() Imports a named attribute in the current tiles definition into the named context.
get() Inserts the named tile into the current tile.
Method Overview
importAttributes() 指定されたコンテキストにカレントのtiles定義にある全ての属性をインポートします。
getAttribute() カレントのtiles定義から指定された属性を返却します。
importAttribute() 指定されたコンテキストにカレントのtiles定義にある指定された属性をインポートします。
get() カレントのtileに指定されたtileを挿入します。
importAttributes()
       

Imports all attributes in the current tiles definition into the named context

void importAttributes()

void importAttributes(String scope)

Parameters
scope
The named context scope to put the attributes into. Possible values are page (velocity-context), request, session, and application.

This method makes it possible to import all attributes, defined in the current tiles definition, into any scope, to be accessed i.e. by other tiles.

Assuming that the tiles config contains the following definition(and ".tilename" is the current tiles definition):

<definition name=".tilename" path="/layout.vm">
    <put name="attr1" value="This is one attribute."/>
    <put name="attr2" value="and this is a another."/>
</definition>

then the following Velocity script:

$tiles.importAttributes()
$attr1
$attr2

produces this output:

This is one attribute
and this is another one

指定されたコンテキストにカレントのtiles定義にある全ての属性をインポートします。

void importAttributes()

void importAttributes(String scope)

Parameters
scope
指定された、属性をインポートするコンテキストのスコープ。 page(velocityコンテキスト)、requestsessionapplicationが指定できます。

このメソッドはカレントのtiles定義にある全ての属性を任意のスコープにインポートすることを可能にします。 インポートされた属性は他のtileよりアクセスできるようになります。

tilesの設定に次の定義が含まれているとして (カレントのtiles定義が".tilename"として):

<definition name=".tilename" path="/layout.vm">
    <put name="attr1" value="これはある属性です。"/>
    <put name="attr2" value="そしてこれは別のです。"/>
</definition>

次のVelocityスクリプト:

$tiles.importAttributes()
$attr1
$attr2

は以下を出力します:

これはある属性です。
そしてこれは別のです。

getAttribute()
       

Returns a named tiles attribute from the current tiles definition

String getAttribute(String attributeName)

Parameters
attributeName
The name of the tiles-definition attribute.
Returns
Returns the named tiles attribute from the current tiles definition

This method makes it possible to fetch any attribute defined in the current tiles definition.

Assuming that the tiles config contains the following definition (and ".tilename" is the current tiles definition):

<definition name=".tilename" path="/layout.vm">
    <put name="attr1" value="This is one attribute."/>
    <put name="attr2" value="and this is a another."/>
</definition>

then the following Velocity script:

$tiles.getAttribute("attr1")

produces this output:

This is one attribute

カレントのtiles定義から指定された属性を返却します。

String getAttribute(String attributeName)

Parameters
attributeName
tiles定義の属性の名前。
Returns
カレントのtiles定義から指定された属性を返却します。

このメソッドはカレントのtiles定義にある任意の属性を取得することを可能にします。

tilesの設定に次の定義が含まれているとして (カレントのtiles定義が".tilename"として):

<definition name=".tilename" path="/layout.vm">
    <put name="attr1" value="これはある属性です。"/>
    <put name="attr2" value="そしてこれは別のです。"/>
</definition>

次のVelocityスクリプト:

$tiles.getAttribute("attr1")

は以下を出力します:

これはある属性です。

importAttribute()
       

Imports a named attribute in the current tiles definition into the named context.

void importAttribute(String attributeName)

void importAttribute(String attributeName, String scope)

Parameters
attributeName
The name of the tiles-definition attribute.
scope
The named context scope to put the attributes into. Possible values are page (velocity-context), request, session, and application.

This method makes it possible to import a named attribute, defined in the current tiles definition, into any scope, to be accessed i.e. by other tiles.

Assuming that the tiles config contains the following definition(and ".tilename" is the current tiles definition):

<definition name=".tilename" path="/layout.vm">
    <put name="attr1" value="This is one attribute."/>
    <put name="attr2" value="and this is a another."/>
</definition>

then the following Velocity script:

$tiles.importAttribute("attr1")
$attr1

produces this output:

This is one attribute

指定されたコンテキストにカレントのtiles定義にある指定された属性をインポートします。

void importAttribute(String attributeName)

void importAttribute(String attributeName, String scope)

Parameters
attributeName
tiles定義の属性の名前。
scope
指定された、属性をインポートするコンテキストのスコープ。 page(velocityコンテキスト)、requestsessionapplicationが指定できます。

このメソッドはカレントのtiles定義にある任意の属性を任意のスコープにインポートすることを可能にします。 インポートされた属性は他のtileよりアクセスできるようになります。

tilesの設定に次の定義が含まれているとして (カレントのtiles定義が".tilename"として):

<definition name=".tilename" path="/layout.vm">
    <put name="attr1" value="これはある属性です。"/>
    <put name="attr2" value="そしてこれは別のです。"/>
</definition>

次のVelocityスクリプト:

$tiles.importAttribute("attr1")
$attr1

は以下を出力します:

これはある属性です。

get()
       

Inserts the named tile into the current tile.

void get(Object attr)

Parameters
attr
The name of the tile to insert.

This method makes it possible to insert a named tile, defined in the current tiles definition, into the velocity template.

Assuming that the tiles config contains the following definition(and ".tilename" is the current tiles definition):

<definition name=".tilename" path="/layout.vm">
    <put name="header" value="/header.vm"/>
</definition>

then the following two Velocity scripts:

<!-- layout.vm -->
<html>
$tiles.header
<body>
    World
</body>
</html>

<!-- header.vm -->
<head>
    <title>Hello</title>
</head>

produce this output:

<html>
<head>
    <title>Hello</title>
</head>
<body>
    World
</body>
</html>

カレントのtileに指定されたtileを挿入します。

void get(Object attr)

Parameters
attr
挿入するtileの名前。

このメソッドはカレントのtiles定義にある、 指定されたtileをvelocityテンプレートに挿入することを可能にします。

tilesの設定に次の定義が含まれているとして (カレントのtiles定義が".tilename"として):

<definition name=".tilename" path="/layout.vm">
    <put name="header" value="/header.vm"/>
</definition>

次のVelocityスクリプト:

<!-- layout.vm -->
<html>
$tiles.header
<body>
    World
</body>
</html>

<!-- header.vm -->
<head>
    <title>Hello</title>
</head>

は以下を出力します:

<html>
<head>
    <title>Hello</title>
</head>
<body>
    World
</body>
</html>


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