Oaf determines that the current transaction has uncommitted changes

Source: Internet
Author: User

Development Requirements

In oaf development, there may be such a requirement. When you select the Save button, if there is changed data, commit the transaction and save it to the database;

If no changed data exists, the system prompts you that no data can be changed.

Solution

Determine whether the view object used in the page has been changed

Method 1: Call the oadbtransaction. isdirty () method

This method is used to determine whether the view object has changed in the current transaction. However, this method is only valid for Object-based view objects. If a query-based view object exists, you need to call PL/SQL to change the database.

Method 2: Call oaviewobject. isdirty ()

This method can be used to determine whether a single view object has been changed, whether it is a view object based on an object or a view object based on a query.

Method 3: Call the getpoststate () method of the object to determine

Sometimes oaviewobject. isdirty () is restricted. If the query is re-executed, the dirty flag of the view object is reset. In this case, you cannot use this method to determine whether a change exists. Instead, you need to use the following method or the fourth method.

CallViewrowimpl. getentity (0). getpoststate ()You can determine whether the object corresponding to the View row has been changed, so that the dirty flag can be reset regardless of whether the View row is re-queried.

Method 4: Use Data Cache

Before entering the page, cache the data to transaction. When saving the button event, compare whether each attribute of the row of the object saved by transaction is consistent with that of the row of the current view object.

The reason for using Method 4 is that if insertrow () exists and the row. Remove () is deleted, the system considers that the view object has unsaved changes. The fourth method can be used to avoid this situation (in general, the customer should be persuaded to accept this situation ).

In addition, if the view object created based on the query is saved to the database using PL/SQL, and the temporary attribute changes exist (row is called. setattribute (), even if the attribute does not need to be saved to the database), you can only use the fourth method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.