Control row updatability – part 2

Environment (JDeveloper 11.1.2.0.0, ADF BC, ADF Faces)

In the previous post, I have shown how to control the row updatability based on some conditions. Another popular use case for row updatability is making the row or some attributes within the row only updatable while the row status is new, but after being successfully committed to the database they should become read-only. In this post I will show how to implement this use case in declarative and programmatic ways.

  • Declarative method:

The Updatable property controls that is available for each attribute within the entity and view objects has a While New option, we can set this property for single, multiple, or all attributes as shown below.

Updatable Property

 

  • Programmatic method:

we can override isAttributeUpdateable method in the EntityImpl class. If we want the entire row to be updatable while it is  new then override  isAttributeUpdateable method as shown below:

  public boolean isAttributeUpdateable(int i) {
        if (getEntityState()!=STATUS_NEW )
            return false;
        else
            return super.isAttributeUpdateable(i);
    }

If we want single or many attributes to be updatable while the row is new, then override  isAttributeUpdateable method as shown below:

public boolean isAttributeUpdateable(int i) {
        /**
         * ID is the attributeEnum.
         * you can add attributesEnum as required
         * by your use case
         */
        if (getEntityState()!=STATUS_NEW && i== ID)
            return false;
        else
            return super.isAttributeUpdateable(i);
    }

 

see also: Control row updatability – part 1.

Advertisements

Leave a comment

Filed under ADF

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s