Wednesday, July 20, 2011

Non-Updateable rows in ADF tables

Read-only row in an ADF table is a very common use case.Last week we had a scenario where in the user is not allowed to modify a row based on a flag.Adding to this, user should not be able to modify some of the columns which are retrieved from the database.

One way to achieve this kind of behavior is through setting the read-only property of the components in the column (like #{row.bindings.Retrieved.inputValue eq 'Y'}). If a table has multiple columns, it would be a laborious process.

To achieve the same one can override the "isAttributeUpdateable" method in the EntityImpl. Following is the code snippet:

// Comment
public boolean isAttributeUpdateable(int index) {
if("Y".equals(getSeededFlag())) return false;
//Description column is always updatable 
// if not a seeded record
if(index!=DESCRIPTION)
{
//If new record, attributes should be updatable
if(this.STATUS_NEW == this.getEntityState() || 
    this.STATUS_INITIALIZED == this.getEntityState())
            return true;
if(this.STATUS_NEW != this.getEntityState() || 
   this.STATUS_INITIALIZED != this.getEntityState())
            return false; 
        }
        
        return super.isAttributeUpdateable(index);
    }

Tuesday, July 5, 2011

Action Event not being raised?

Last week i have faced a weird issue where in an action event on a command component (command image component) being suppressed (Suppressed is a wrong word, i learnt it later :) ).

Following is my learning:

That component's disable property was handled via managed bean based on some condition. In one scenario, i have set the property from false to true, but failed to add partial trigger on the component. Thus component's disable property was set to true, but the component is still enabled on the UI. Now, when i pushed this command component, all i was expecting is the execution of my action event and it didnt happen.

Following are the points that i have observed:

In a request life cycle, for every phase, there can be events which are queued up. For example, Value Change Events in APPLY_REQUEST_VALUES phase, Action events in INVOKE_ACTION phase etc., While executing the each phase, all the events that are queued up will be broadcasted for listeners.

In my case, i have a listener, but the event is not broadcasted, reason being, the component is not in the UIViewRoot (It was disabled). Hence, for an event to be broad casted, corresponding component should be active. Thus, i admit that, the event is NOT suppressed, but it was never broadcasted and i take all the blame :)