ADF Quirks, Bugs & Hints

person Bijeshfolder_openADFlocal_offer, , access_time November 26, 2010

ADF Table shows duplicate rows on CreateInsert

My particular page had a master-detail-detail editable table on it with a “CreateInsert” operation. The first time I hit the createInsert button the page came back with a clean empty row. Every consecutive createInsert operation resulted in a duplicate of the first created row. What was weird was that in debug mode, I could trace the create operation on the view object and the entity object so I knew that a new row was getting created. Even weirder was the fact on dropping a read only column for the primary key attribute, this particular column alone showed freshly created data.

After spending some time breaking my head over this, I came across this post on the forum – http://forums.oracle.com/forums/thread.jspa?messageID=4579932&#4579932. So, it appears that ADF treeTable binding requires that the source attribute of a ViewLink is a key attribute on the master data source. My View Links were based on multiple attributes and not all of them were a primary key in the database (although they should’ve been). I went ahead and made the source attributes at each ViewLink level part of the primary key on the corresponding entities. And voila! It worked. Lesson Learnt – Set up primary keys on the entities even if the database design does not specify them.

UserPrincipal missing in ADF context

This is apparently a bug in ADF 11.1.3. The UserPrincipal does not propagate to the ADF session. My application had a no. of queries that used the logged in user’s id as the bind variable’s value. I had used the Groovy expression  – “viewObject.DBTransaction.session.userPrincipalName”. Unfortunately, none of my queries worked as expected. After furious Googling, I found out that this was a bug in ADF 11.1.3. Luckily enough, there is another way to fetch the UserPrinicpal – through ADFContext. The code for this – “ADFContext.getCurrent().getSecurityContext().getUserName();”.

To further simply this, I overrode the prepareSession method in my Application Module. In the overridden method, I fetched the user name from ADFContext and set the value into the session.
“session.getEnvironment().put(PropertyMetadata.USER_PRINCIPAL.getName(), currentUserName);”

protected void prepareSession(Session session) {
        super.prepareSession(session);
        String currentUser =
            ADFContext.getCurrent().getSecurityContext().getUserName();
        session.getEnvironment().put(PropertyMetadata.USER_PRINCIPAL.getName(),
                                         currentUser);
    }

Thanks to Andrejus for his post on the bug.

ADF Bug(?): Multiple entities with same attribute names cause ADF BC Validation errors to display incorrectly

This requires a post for itself. Coming up soon.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>