Using Try, Catch, and DisplayException

To insert a try component and use catch and displayException:

  1. In the Design Structure Window of the desired file, locate the node in which you wish to insert a try component.
  2. In the Component Palette, select Miscellaneous Components from the dropdown list, and then drag and drop the try component to the parent node of your choice.

    The try node is inserted and highlighted under the expanded parent node.

  3. In the Property Inspector, set the following attributes for the try component:
  4. To add indexed children to a try component, do the following:
    1. In the Design Structure Window, right-click the try node and choose Insert inside try ... to insert any component.
    2. In the Property Inspector, set the attributes for the indexed child component.
  5. To use the catch and displayException components, do the following:
    1. In the Design Structure Window, expand the try node to uncover the catch named child node.
    2. Right-click the catch node and choose Insert inside catch | displayException.

      The displayException node is inserted and highlighted under the expanded catch node.

Note: To use data binding, see Data Binding a Component Attribute.

Example (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> ...

About Try
About Catch
About DisplayException

Working with Simple and Miscellaneous Components

 

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