1

バックグラウンド

マネージド Bean には、その web.xml ファイルを介して構成されたパラメーターが必要です。web.xml ファイルでは、JDeveloper (11.1.2.3)で構成されるコンテキスト初期化パラメータが次のように定義されています。

ここに画像の説明を入力

定義のソースは次のreporting.server.protocolとおりです。

  <context-param>
    <description>Defines the data transport mechanism to ret...</description>
    <param-name>reporting.server.protocol</param-name>
    <param-value>http</param-value>
  </context-param>

Bean は、 のパブリック アクセサ メソッドを公開しますreportServerProtocol

Bean のソースは次のようになります。

@ManagedBean
@RequestScoped
public class OracleReportBean extends ReportBean {

  @ManagedProperty("#{initParam['reporting.server.protocol']}")
  private String reportServerProtocol = URLReportImpl.DEFAULT_PROTOCOL;

  // ...
}

問題

FacesContextではなく、コンテキスト初期化パラメーターを使用して Bean を初期化したいと思います。(adfc-config.xml注: ではありませんfaces-confg.xml) では、いくつかの例で への参照が示されていinitParamます。

<managed-bean>
  <managed-bean-name>reportBean</managed-bean-name>
  <managed-bean-class>ca.corp.report.view.OracleReportBean</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>
  <managed-property>
    <property-name>reportServerProtocol</property-name>
    <property-class>java.lang.String</property-class>
    <value>#{initParam['reporting.server.protocol']}</value>
  </managed-property>
...
</managed-bean>

値要素であるキー行#{initParam['reporting.server.protocol']}。ただし、JDeveloper はその行を正しくないと表示します。つまり、initParamコンテキストは 内では使用できませんadfc-confing.xml

エラーは、「EL トークンinitParamが不明です」です。

質問

ELを使用して、ADFc内で宣言的にマネージドBeanを構成するためにコンテキスト初期化パラメータをどのように使用できますか?

関連リンク

4

2 に答える 2

1

JDeveloper のバグにより、次のエラーが表示されます。

JDeveloperエラー

ただし、IDE にエラーが表示されても、コードは期待どおりに実行されます。

于 2013-03-05T18:21:37.377 に答える
0

UIレイヤーでは、次のようなものを試すことができます。

<c:set target="${BeanName}" property="PropertyName" value="${true}"/>
于 2013-02-02T12:17:44.170 に答える