ViewObject Show

Oracle ADFのビュー・オブジェクトから標準XMLデータをレンダリングします。オプションで、ビュー・リンクで結合された関連ビュー・オブジェクトを任意のレベルまでネストします。

処理ハンドラ・クラス

oracle.xml.xsql.ViewObject

構文

<xsql:action handler="oracle.xml.xsql.ViewObject"
  name="SomeView"
  appmodule="fully.qualified.AppModuleName"
  connname="someconnection"
/>

connnameの有効な値は、サーバーのクラスパスのXSQLConfig.xmlファイルに格納されているXSQL接続定義です。JDeveloperでは、この接続定義は通常、<JDev_install>\system###内にあります。

name属性は、アプリケーション・モジュールでのビューの名前と一致している必要があります。

(connnameを使用する)このアプローチでは、Business Components for Javaはローカル・モードでのみ使用されます。

また、ユーザーがアプリケーション・モジュール構成を使用し、アプリケーション・モジュールの接続情報を指定することもできます。この場合、connname属性は指定せず、同じ場所にconfigname属性を指定してください。

<xsql:action handler="oracle.xml.xsql.ViewObject"
  name="SomeView"
  appmodule="fully.qualified.AppModuleName"
  configname="someconfigname"/>

confignameの有効な値は、アプリケーション・モジュールが含まれるパッケージのパッケージ・ディレクトリの、./commonサブディレクトリ内にあるbc4j.xcfgファイルに定義されている構成です。したがって、アプリケーション・モジュールがa.b.c.MyModuleであれば、有効なconfignameは、ランタイム・クラスパス内のファイル ./a/b/c/common/bc4j.xcfg内にあります。

説明

Oracle ADFのビュー・オブジェクトから標準XMLデータをレンダリングします。オプションで、ビュー・リンクで結合された関連ビュー・オブジェクトを任意のレベルまでネストします。

ビジネス・コンポーネント用のXSQL処理ハンドラは、IDEのJBO HTMLライブラリの一部としてパッケージ化されており、関連する<JDev_install>/BC4J/jlib/bc4jhtml.jarアーカイブがビルドに含まれています。

このトピック内にある様々なオプションの属性以外にも、オプションで<where>要素を<xsql:action handler="oracle.xml.xsql.ViewObject">タグ内部にネストした場合、例による問合せ機能を実行できます。<where>要素には、その属性名に対する例による問合せ基準を指定するために、ネストした<attribute>要素をいくつでも含めることができます。

<xsql:action handler="oracle.xml.xsql.ViewObject"
   name="ViewUsageName"
   appmodule="fully.qualified.AppModuleName"
   configname="someconfigname">

  <where>
    <attribute name="attrname1" value="someval2"/>
    <attribute name="attrname2" value="someval2"/>
  </where>
</xsql:action>

他のXSQL処理ハンドラの場合と同様に、XSQLの属性は、属性値が指定されている場所であればどこでも使用できるため、次のようにパラメータ値を用いて、全体またはその任意の一部を導出できます。

<xsql:action handler="oracle.xml.xsql.ViewObject"
   name="ViewUsageName"
   appmodule="fully.qualified.AppModuleName"
   configname="someconfigname">

  <where>
    <attribute name="{@attr}" value="{@val}"/>
  </where>
</xsql:action>

また、oracle.jbo.xsql.ViewObject処理ハンドラの内部にネストされる要素として<view-attribute-list>があります。この<view-attribute-list>要素を使用すると、インクルードする属性をリストした追加のメタデータを、ビュー・オブジェクトごとに指定できます。

特定のビュー・オブジェクト(viewdefname)に対して<view-attribute-list>要素をインクルードしない場合、デフォルトでは、そのビューに対してすべての属性がインクルードされます。<xsql:action>要素のネストされた子として配置する必要がある、<view-attribute-list>要素の構文は次のとおりです。

<view-attribute-list
  viewdefname="String"
  include-only="Space-or-comma-separated-list-of-attr-names"/>

スペース区切りまたはカンマ区切りのinclude-only="xx yy zz"に含まれる属性名の順番には意味があります。次に例を示します。

<view-attribute-list
  viewdefname="foo.barView"
  include-only="EmpName Salary"/>

この場合、属性Salaryの前に属性EmpNameを持つXMLが作成されます。

<view-attribute-list
  viewdefname="foo.barView"
  include-only="Salary EmpName"/>

この場合は、属性EmpNameの前に属性Salaryを持つXMLが作成されます。

次の例は、<view-attribute-list>要素の使用方法を示しています。

<xsql:action handler="oracle.jbo.xsql.ViewObject"
    name="DepartmentsView"
    appmodule="test.HRModule"
    configname="HRModuleLocal"
    dlist="DepartmentName EmployeesView"
    name=""
    elist="FirstName LastName">

  <!-- This part does a query-by-example on the department name
    based on the value of the HTTP URL parameter "name" -->

  <where>
    <attribute name="DepartmentName" value="{@name}"/>
  </where>

  <!-- This part specifies that for any view rendered of
    viewdef-type "test.EmployeesView", only the attributes
    listed in the value of the "elist" parameter will be
    included. Of course, the list of attributes could be
    hard-coded instead of based on a parameter, too. -->

  <view-attribute-list viewdefname="test.EmployeesView"
       include-only="{@elist}"/>

  <!-- This part specifies that for any view rendered of
    viewdef-type "test.DepartmentsView", only the attributes
    listed in the value of the "elist" parameter will be
    included. Of course, the list of attributes could be
    hard-coded instead of based on a parameter, too. -->

  <view-attribute-list viewdefname="test.DepartmentsView"
    include-only="{@dlist}"/>
</xsql:action>

循環ビュー・リンク・アクセッサを使用してビュー・オブジェクトを問い合せる際の注意点

複数の表の間に外部キー関係がある場合を考えてみます。たとえば、Oracle9iリリース2のデータベース・サンプルのHRスキーマでは、国、部門、従業員および場所の表の間にこのような関係があります。これらの表に基づいて単純なビジネス・コンポーネント・プロジェクトを作成し、さらにCountriesView1というビュー・オブジェクトにアクセスするXSQLクライアントを作成すると、次のようなエラーが発生します。

<?xml version="1.0" encoding="windows-1252" ?>
- <!--
| Uncomment the following processing instruction and replace
| the stylesheet name to transform output of your XSQL Page using XSLT
<?xml-stylesheet type="text/xsl" href="YourStylesheet.xsl" ?>

-->
- <page>
- <xsql-error action="xsql:action">
  <message>JBO-27122: SQL error during statement preparation. Statement: SELECT Employees.EMPLOYEE_ID, Employees.FIRST_NAME, Employees.LAST_NAME, Employees.EMAIL, Employees.PHONE_NUMBER, Employees.HIRE_DATE, Employees.JOB_ID, Employees.SALARY, Employees.COMMISSION_PCT, Employees.MANAGER_ID, Employees.DEPARTMENT_ID, Employees.DN FROM EMPLOYEES Employees WHERE (Employees.DEPARTMENT_ID = :1)</message>
  </xsql-error>
  </page>

このエラーは、max-levelsパラメータにデフォルト値を使用して、基礎となるwriteXML()メソッドを使用しているために発生します。このため、前述した外部キーによって作成される循環参照により無限ループが発生し、ORA-1000のMaxOpenCursors超過エラーが内部で発生します。

このエラーを回避するには、コードを次のように変更します。

<xsql:action handler="oracle.jbo.xsql.ViewObject"
      name="YourViewUsageName"
      appmodule="a.b.c.YourModuleName"
      configname="YourModuleNameLocal">
   <view-attribute-list viewdefname="a.b.c.YourViewName"
         include-only"Attr1 Attr2 Attr3"
       :
</xsql:action>

属性リストを制御する各ビュー定義に複数の<view-attribute-list>要素を使用できます。1つの<view-attribute-list>要素を使用するとすぐに、<view-attribute-list>要素に含まれている属性のみをインクルードするwriteXML()の新しいAPIが使用されます。

ディテールのビュー・オブジェクトを表示するには、そのビュー定義のinclude-onlyリストにある属性名のリストに、ビュー・リンク・アクセッサ属性名を含める必要があります。

次に、CountriesViewに基づく例を示します。

<?xml version="1.0" encoding='windows-1252'?>
<!--
| Uncomment the following processing instruction and replace
| the stylesheet name to transform output of your XSQL Page using XSLT
<?xml-stylesheet type="text/xsl" href="YourStylesheet.xsl" ?>
-->
<page xmlns:xsql="urn:oracle-xsql">
    <xsql:action
    handler="oracle.jbo.xsql.ViewObject"
    name="CountriesView1"
    configname="HrModuleLocal"
    appmodule="hr.HrModule">
    <view-attribute-list viewdefname="hr.HrModule.CountriesView"
    include-only="CountryId CountryName CurrencyName" />
    </xsql:action>

</page>

属性

 

 

Copyright © 1997, 2004, Oracle. All rights reserved.