Dive into BC4J and ADF

Send me a mail
 Dive into BC4J and ADF    Click to see the XML version of this web page.   (Updated: 6/3/2006; 11:49:55 AM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper 10g

Search blog with Google:
 

Search BC4J JavaDoc:
 

November 2003
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
Oct   Dec

Get Firefox!

Wednesday, November 19, 2003

A customer writes in to ask:

Imagine that we need to do something after all setXXXX for all the attributes of a Row object.That is our need. But we do not want to call this method when the based Entity in the view object is readonly. So in certain situations , we do not want to run the custom code. One of this situation is when the Entity object in the view object  was in readonly mode.

A sensible thought was to write code in the setAttributeInternal method of a custom framework extension class like this:

package demo.fwkext;
import oracle.jbo.server.ViewRowImpl;
public class CustomViewRowImpl extends ViewRowImpl {
  /**
   * Do something custom after every attribute set in a view row
   *
   * @param index Attribute index "slot" number in the view row
   * @param val Object value being set
   */
  protected void setAttributeInternal(int index, Object val) {
    super.setAttributeInternal(index, val);
    // Do your thing here
  }
}

The customer's first thought was to generically look at the EntityReference object (in a view object definition, there will be one EntityReference for each entity object being used by a result row in this view), which was a smart idea, but unfortunately the EntityReference object is package private to oracle.jbo.server at present, so another strategy is needed. I've filed a bug to make that object accessible in a future release, but we provide today the isAttributeUpdateable() API which would allow you to make your custom framework extension code conditional like this:

package demo.fwkext;
import oracle.jbo.server.ViewRowImpl;
public class CustomViewRowImpl extends ViewRowImpl {
  /**
   * Conditionally do something custom after every attribute set in a view row
   *
   * @param index Attribute index "slot" number in the view row
   * @param val Object value being set
   */
  protected void setAttributeInternal(int index, Object val) {
    super.setAttributeInternal(index, val);
    if (isAttributeUpdateable(index)) {
      // Do your thing here
    }
  }
}

This alternative approach should work in any BC4J 9.0.2 or later to achieve the desired result.


11:50:55 AM    



© Copyright 2006 Steve Muench.