値バインディング式で参照されると動的にインスタンス化されて構成済の有効範囲内に格納されるJSFマネージドBeanを宣言します。ただし、Beanのインスタンスが現在の有効範囲に存在しないことが必要です。
1つ以上のmanaged-property
要素を宣言して、マネージドBeanのプロパティ(Beanのマップ・プロパティまたはリスト・プロパティを含む)を設定値で初期化します。プロパティは、対応するBeanがインスタンス化されると動的に設定されます。構成ファイルで宣言されていないBeanのプロパティは設定されません。
MapEntries
要素を宣言して、java.util.Map
にキーと値のペアを移入します。
ListEntries
要素を宣言して、java.util.List
に値を移入します。
<managed-bean>
[<
description
/>]*
[<
display-name
/>]*
[<
icon
/>]*
<
managed-bean-name
>beanName</managed-bean-name>
<
managed-bean-class
>beanClass</managed-bean-class>
<
managed-bean-scope
>
none | request | session | application
</managed-bean-scope>
[
<managed-bean-extension>
proprietary elements</managed-bean-extension>]
[<
ManagedProperty
>*|<
MapEntries
>|<
ListEntries
/>]
</managed-bean>
ManagedProperty
::=
<managed-property>
[<
description
/>]*
[<
display-name
/>]*
[<
icon
/>]*
<
property-name
>
propertyName</property-name>
[
<
property-class
>
propertyClass</property-class>]
[<
Value
>|<
MapEntries
>|<
ListEntries
>|
<
null-value
/>
]
</managed-property>
Value
::=
<
value
>
simplevalue
</value>
MapEntries
::=
<
map-entries
>
[<
key-class
>KeyClass</key-class>]
[
<
value-class
>
valueClass
</value-class>
]
<
map-entry
>
<
key
>
key
</key>
<
value
>
value
</value>
|
<
null-value
/>
</map-entry>*
</map-entries>
ListEntries
::=
<
list-entries
>
[
<
value-class
>
valueClass
</value-class>]
<
value
>
value
</value>
|
<
null-value
/>
</list-entries>
<managed-bean-name>
<managed-bean-class>
java.util.Map
またはjava.util.List
の実装であることが可能です。
<managed-bean-scope>
none
: アプリケーションがマネージドBeanにアクセスするたびに、マネージドBeanを作成して初期化します。 request
: Beanが作成されたHTTPリクエストの存続期間中、Beanは保持されます。session
: Beanが作成されたHTTPセッションの存続期間中、Beanは保持されます。application
: アプリケーションが実行されている間、Beanは保持されます。<managed-bean-extension>
managed-property
<map-entries>
<
key-class>
子要素(オプション)、<value-class>
子要素(オプション)、および1つ以上の<map-entry>
子要素。<list-entries>
<value-class>
子要素(オプション)、および1つ以上の<value>
子要素。 <property-name>
<property-class>
<map-entries>
<
key-class>
子要素(オプション)、<value-class>
子要素(オプション)、および1つ以上の<map-entry>
子要素。<list-entries>
<value-class>
子要素(オプション)、および1つ以上の<value>
子要素。 <key-class>
String
のままです。<map-entry>
<key>
子要素、および1つの<value>
子要素。
<key>
String
表現を定義します。<key-class>
に変換可能な文字列。<value>
Beanの有効範囲 | 参照可能なBeanの有効範囲 |
---|---|
none | none |
application | none、application |
session | none、application、session |
request | none、application、session、request |
<value-class>
<list-entries>
または<map-entries>
要素に追加される前に変換されます。この要素を宣言しないと、値はString
のままです。<null-value>
<property-class>
がJavaプリミティブ型に設定されている場合、この要素は使用できません。#{tax.rate}
を使用してインスタンス化されると、rate
プロパティは値5で初期化されます(Float
に変換されます)。<managed-bean>
<managed-bean-name>tax</managed-bean-name>
<managed-bean-class>com.jsf.databeans.TaxRateBean</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>rate</property-name>
<property-class>java.lang.Float</property-class>
<value>5</value>
</managed-property>
</managed-bean>
map
のマネージドBean。アプリケーションでEL式#{errorcodes.error}
が検出されると、ErrorCodes
オブジェクトがインスタンス化され、error
プロパティのキーと値のペアは、宣言されたmap-entry
ペアの値で初期化されます。<managed-bean>
<managed-bean-name>errorcodes</managed-bean-name>
<managed-bean-class>com.jsf.databeans.ErrorCodes</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>error</property-name>
<property-class>java.util.HashMap</property-class>
<map-entries>
<key-class>java.lang.Integer</key-class>
<map-entry>
<key>300</key>
<value>Invalid entry</value>
</map-entry>
<map-entry>
<key>400</key>
<value>No such value</value>
</map-entry>
<map-entry>
<key>500</key>
<value>Internal server error</value>
</map-entry>
</map-entries>
</managed-property>
</managed-bean>
#{options.text}
が検出されると、List
オブジェクトが作成されて、宣言されたlist-entries
の値で初期化されます。managed-property
要素が宣言されていないかわりに、list-entries
がmanaged-bean
要素の子要素であることに注意してください。 <managed-bean>
<managed-bean-name>options</managed-bean-name>
<managed-bean-class>java.util.ArrayList</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
<list-entries>
<value>Text Only</value>
<value>Text + HTML</value>
<value>HTML Only</value>
</list-entries>
</managed-bean>
<description>要素
<display-name>要素
<icon>要素
<attribute>要素
<property>要素
リファレンス: JSF構成要素
Copyright © 1997, 2009, Oracle. All rights reserved.