try、catchおよびdisplayExceptionの使用

tryコンポーネントを挿入し、catchおよびdisplayExceptionを使用するには、次のようにします。

  1. 目的のファイルの設計構造ウィンドウで、tryコンポーネントを挿入するノードを探します。
  2. コンポーネント・パレットのドロップダウン・リストから「Miscellaneous Components」を選択し、tryコンポーネントを、選択した親ノードにドラッグ・アンド・ドロップします。

    「try」ノードが、展開された親ノードに挿入され、強調表示されます。

  3. プロパティ・インスペクタで、tryコンポーネントに対して次の属性を設定します。
  4. 索引付けされた子をtryコンポーネントに追加するには、次のようにします。
    1. 設計構造ウィンドウで、「try」ノードを右クリックし、「tryの中に挿入」を選択してコンポーネントを挿入します。
    2. プロパティ・インスペクタで、索引付けされた子コンポーネントの属性を設定します。
  5. catchおよびdisplayExceptionコンポーネントを使用するには、次のようにします。
    1. 設計構造ウィンドウで、「try」ノードを拡張して、名前付きの子「catch」ノードを表示します。
    2. 「catch」ノードを右クリックし、「catchの中に挿入」->「displayException」を選択します。
    3. 「displayException」ノードが、展開された「catch」ノードに挿入され、強調表示されます。

注意: データ・バインディングの使用は、「コンポーネント属性のデータ・バインディング」を参照してください。

例(UIX XML)


...
<page xmlns="http://xmlns.oracle.com/uix/ui"
      xmlns:ui="http://xmlns.oracle.com/uix/ui"
      expressionLanguage="el">
<content> <dataScope xmlns="http://xmlns.oracle.com/uix/ui"> <provider> <!-- A data provider that will always fail, throwing a SQLException --> <data name="problem"> <method class="oracle.cabo.servlet.demo.DemoData" method="throwException" /> </data> <!-- A data provider that succeeds --> <data name="noproblem"> <instance class="oracle.cabo.servlet.demo.DemoData" /> </data> </provider> <contents> <!-- This "try" will succeed without any problems --> <try> <contents> <pageLayout> <contents> <styledText text="${uix.data.noproblem['1Text']}"/> </contents> </pageLayout> </contents> <catch> <!-- So you'll never see this --> <messageBox text="An error!" /> </catch> </try> <!-- But this "try" will fail --> <try> <contents> <pageLayout> <contents> <styledText text="${uix.data.problem['1Text']}"/> </contents> </pageLayout> </contents> <catch> <!-- So you'll reach this portion --> <header messageType="error"> <!-- And here's a simple example of getting the exception that caused the problem --> <boundAttribute name="text"> <contextProperty select="ui:currentThrowable" /> </boundAttribute> </header> <!-- or this section --> <!--catch> <displayException /> </catch--> </catch> </try> </contents> </dataScope> </content> </page> ...

tryについて
catchについて
displayExceptionについて

単純なコンポーネントおよびその他のコンポーネントの使用

 

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