<try>要素 |
![]() |
ネームスペース: | http://xmlns.oracle.com/uix/ui |
派生元: | <ui:base>要素 |
グループ: | UIX Components |
要素の型: | UINode |
構文 |
![]() |
<try> <catch></catch> <contents><!-- indexed children --></contents> </try>
説明 |
![]() |
<try>要素を使用すると、開発者は、エラーを起こす可能性のあるページのセクションを、不完全な出力を行う危険をおかさず実行できます。 すべての出力は、そのセクションが正常に完了するまでバッファリングされます。 出力に失敗した場合、レンダリングは<catch>要素に引き継がれます。 この子は、UIXネームスペースおよびcurrentThrowableキーで、エラーを発生させた例外であるRenderingContextのプロパティにアクセスします。 多くの場合、Java開発者は、未チェックの例外を認めないインタフェース(UIX DataObjectインタフェースなど)により制約を受けます。 これらのインタフェースでは、Java RuntimeExceptionのみが有効です。 解決手段は、実際の例外をラップするoracle.bali.share.util.UnhandledExceptionクラスの使用です。 <try>要素は、このクラスのインスタンスを自動的にアンラップします。
例 |
![]() |
<try xmlns="http://xmlns.oracle.com/uix/ui">
<contents>
<!-- Assume the following request throws an exception -->
<styledText text="${problem.veryBadKey}"/>
</contents>
<catch>
<header messageType="error">
<boundAttribute name="text">
<!-- A UIX example of a cheap way to display the exception -->
<contextProperty select="ui:currentThrowable"/>
</boundAttribute>
</header>
</catch>
</try>
子要素 |
![]() |
|