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
|