14.01.2013 Views

Oracle JHeadstart Developer's Guide - Downloads - Oracle

Oracle JHeadstart Developer's Guide - Downloads - Oracle

Oracle JHeadstart Developer's Guide - Downloads - Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

It is also possible to let the user order the records as desired in a page with table format.<br />

See chapter 5, section “Allowing the user to sort data in a table page” for more detail on<br />

how to do this.<br />

3.3.6. Creating Calculated or Transient Attributes<br />

Sometimes you want to show an attribute that does not exist in the correct form in the<br />

database. For example: you want a read-only attribute FULL_NAME based on the<br />

FIRST_NAME and LAST_NAME attributes. In such cases, you need to add a calculated<br />

or transient attribute.<br />

Note the important difference between a calculated and a transient attribute:<br />

• A calculated attribute is present in the SQL query: the calculation is done by SQL<br />

at retrieval time. So a calculated attribute is only recalculated when the query<br />

is re-executed. Imagine a calculated attribute FullName that is a concatenation<br />

of FirstName and LastName. When the FirstName is changed in the<br />

application, the data needs to be requeried to refresh FullName. Only use a<br />

calculated attribute for read-only fields.<br />

• A transient attribute is not present in de SQL query. You have to calculate the<br />

value in a get method in the View Object. Every time the transient attribute<br />

value is needed, the get method is called and the transient value is<br />

recalculated. So you have no synchronization issues when using a transient<br />

attribute. The only drawback of a transient attribute is that you have to code a<br />

get method in the ViewRowImpl class.<br />

Reference: See also the <strong>Oracle</strong> Application Developer Framework Developer’s<br />

<strong>Guide</strong> for Forms/4GL Developers Release 10.1.3, section 7.6: Adding<br />

Calculated and Transient Attributes to an Entity-Based View Object.<br />

3.3.6.1. Steps to create a calculated attribute<br />

1. Select the View Object, right mouse click, select Edit to open its<br />

Properties dialog.<br />

2. Go to the Attributes node and click on 'New'.<br />

3. Enter an appropriate name for the attribute.<br />

4. Check ‘Mapped to Column or SQL’.<br />

5. Give the attribute an alias.<br />

6. In the Expression text area, key in the SQL expression to create the concatenated<br />

string. Note that if you have included lookup attributes in your view definition,<br />

then you must include the alias you have given to the selected entity objects in<br />

the SQL Expression:<br />

For example: LAST_NAME || ', ' || FIRST_NAME<br />

<strong>JHeadstart</strong> <strong>Developer's</strong> <strong>Guide</strong> Creating ADF Business Components 3 - 19

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!