Control row updatability – part 1

Environment (JDeveloper 11.1.2.0.0, ADF BC, ADF Faces)

Sometimes developers want to make an entire row as read only based on some conditions, As an example assume that you have an application that allows users to apply for something, once the application is approved they are not allowed to modify any attribute instead they can only see their application, this can be done by setting the read only property for each attribute from the property inspector. However, doing this is a headache approach especially if you want to repeat this in many pages and your row contains many attributes.

To implement such similar case in effective approach, we can override the isAttributeUpdateable method either in the EntityImpl class or in the ViewRowImpl class. If you want your row to be non updatable regardless of the view object being used, then override the isAttributeUpdateable method in the EntityImpl class otherwise override the method in your ViewRowImpl class.

The steps required to do this are, (assumed we need to override the isAttributeUpdateable method in EntityImpl class).

  1. generate your custom EntityImpl class.
  2. Assumed that your EntityImpl class is opened in Jdeveloper main window, click on the source menu, then select Override methods  as shown below.

    Override isAttributeUpdateable method

  3. The Override methods window will open, select the isAttributeUpdateable method and click OK as shown below.

    Select isAttributeUpdateable method

  4. Now override your method based on your condition as shown below:

    public boolean isAttributeUpdateable(int i) {
//you can add your condition here
     //in this case Flag attribute indicates whether
    //an application is approved or not
if (this.getFlag().equals(“Y”))
return false;
else
return super.isAttributeUpdateable(i);
}


see also:  Control row updatability – part 2.

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