Updating a Row

Once you have retrieved a row (either by inserting it or navigating to it; see the related topics list for more information), you can change attribute values in the row. If the row contains persistent attributes, these will be changed in the entity cache and posted to the datasource when requested. For more information, see the related topics list.

You can change attribute values in one of two ways: call setAttribute() or use accessors.

Calling setAttribute()

Call setAttribute() on the Row, passing the name of the attribute in as a String and the value of the attribute in as any Object:

currentRow.setAttribute("OrderId", new Number(1));

Warning: If you use an incompatible Java type for the value, you will get a ClassCastException at runtime.

Using Accessors

If you have exposed accessors for the view object, you can instead:

  1. Make sure you have imported the common subpackage of the package containing your view object definition. For example, if your view object is defined in orderentry.datamodel, you would use:

    import orderentry.datamodel.common.*;

  2. Cast the Row to your custom view row interface (generally the name of the view object definition, plus the word "Row" at the end, e.g., OrdersViewRow):

    OrdersViewRow currentOrder = (OrdersViewRow) currentRow;

    Note: You can also cast the Row at the same time you retrieve it.

  3. Call the typesafe setter for the attribute (the getter name is the name of the attribute plus the word "set" at the beginning, e.g., setOrderId()) , passing in the value of the attribute using its true Java type (this will be checked at compile time):

    currentOrder.setOrderId(new Number(1));


Ways to Manipulate Data
About Oracle ADF View Objects
About Oracle ADF Entity Objects
About Oracle ADF Business Components Cache Management
Posting Data Without Committing
Committing a Transaction
Ways to Navigate Through Query Results
Inserting a Row
Retrieving Attribute Values
Implementing Business Logic

 

 

 

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