Archive for the ‘ADF’ Category

ADF active data model

February 3, 2006

This link explains how a change to model is automatically notified to client in case of ADFBC, so that there is no need to transfer the data back and forth.

ADF : Class Casting Exception with ApplicationModule

October 13, 2005

1. I have written my Base applicationmodule(say, CatalogApplicationModuleImpl) extending ApplicationModuleImpl in my frameworkextension Project.
2. Then in the Model project which is dependent on this fwkextension project, I write my ApplicationModule(say, CatalogServiceImpl) extending CatalogApplicationModuleImpl.
3. Then I expose some of the methods of CatalogServiceImpl through a interface CatalogService to the DataAction classes in controller.
4. Now similar to AM, I’ve base controller CatalogDataForwardAction in fwkextension project which is extended by the actual dataaction classesin the viewController project. In the base controller i’ve the utility method:

protected CatalogApplicationModuleImpl getApplicationModule(String dataControlName,DataActionContext ctx)
{DCDataControl dc = ctx.getBindingContext().findDataControl(dataControlName);
if ((dc != null) && dc instanceof DCJboDataControl)
{return (CatalogApplicationModuleImpl) dc.getDataProvider();}
return null;}

5. This is the same method as in Toystore project of SMUENCH. The changeis I’m casting the CatalogServiceImpl(from dc.getDataProvider()) to itsbase class CatalogApplicationModuleImpl, so that I can invoke some methodson the base AM(CatalogApplicationModuleImpl) from the base controller(CatalogDataForwardAction). I need this since I’m writing some methods inthe base controller which need not be replicated in all the controllers implementing this class.
6. The problem is that the above casting fails. I understand that by the above I’m trying to cast a class to a Impl class which is not present in the client side(controller) and hence this exception. If that is the case, what is the wayI can access the methods in the base AM(CatalogApplicationModuleImpl)from the base controller(CatalogDataForwardAction)(these two classesare present in the fwkExtension project). i.e., how can I expose theCatalogApplicationModuleImpl to the controller(should I have to writethis Impl as implementing some interface and use that interface in thebase controller. If so, where should the base interface be created?
Thanks,Krishna.

ADF:Setting of who columns(Audit columns) in the Entity Object

October 13, 2005

Posted the following question in jdeveloper forum today
I have who columns like created_by, creation_date, last_update_date, last_updated_by etc., in the table(and so the entity object). These need to get set based on the user logged in. Currently, I’m achieving the same by following logic:
1. Wrote my own TransactionImpl extending DBTransactionImpl2 and registeredthe transaction factory to the application module.
2. In my transactionImpl, there is a setter method: public void setUserId(int userId)
3. I’ve a filter to redirect the user to login page if not logged in. In the filter Istore the userid in the session, if user is authenticated.
4. Everytimein the DataAction PrepareModel phase, I invoke the methodsetUserId on the applicationModule passing the value from the session, whichsets the same in the TransactionImpl. Then in the EntityObject create method,I access this value to set the userId. I call the setter in all theaction class(so that if in the next request I get a different application moduleor a different transaction due to transaction/AM harvesting, the statevariable may be lost and hence in the preparemodel phase i explicity set them). Is this correct or any other way I can achieve the same
5. My next question is : how do I set these last_update_date and last_updated_by when the entity object is queried and changed. I can do thisin SetAttributeInternal Method(with a check that the index is not these twoattributes). However, this logic will then become tied to a particular entityobject. I want this logic to be written in my base class of EntityImpl so thatall EntityImpl extending my base EntityImpl will have this logic incorporatedautomatically.
Please let me know how can I acheive this.
Thanks,Krishna.

Struts html checkbox : unchecked is not getting posted

September 2, 2005

Recently posted a question in oracle jdeveloper forum :
If a struts html checkbox is unchecked, then when submitting this form containing this checkbox, the checkbox value is not getting posted. Hence, the same is not getting reflected in themodel. So, to post the unchecked value also, what should I do?
Got the reply:
Read the Struts newbie FAQ : http://struts.apache.org/faqs/newbie.html#checkbox

ADF Event handling precedence

July 22, 2005

When an event named YourEvent fires, then…

If you have apublic void onYourEvent(DataActionContext ctx) method in the data action class handling the request, it will be invoked to handle the event with custom code.
If you have an action binding in the current binding container named YourEvent, it will be invoked.

When used in combination with 1, your event-handler code needs to explicitly invoke the default action for the current event by using code like:

if (ctx.getEventActionBinding() != null) ctx.getEventActionBinding().doIt();
If you have a Struts forward named YourEvent, it will be used to determine the next page to forward control to.

When used in combination with 1, if your event-handling code invokes ctx.setActionForward(), then your programmatically set forward takes precedence.

ADF : Creating PreparedStatements

July 21, 2005

While creating preparedStatement from Application Module, it is better to not close them in a finally block. But, close them in the overridden remove() method of the AM by calling some method which will close all the local statements. Thus, will improve performance.

Steps to dynamically bind a dynamically created view object

May 22, 2005

1. Expose the method recreateDynamicViewObjectWithNewQuery(String newSQL) to the client in the AM. This method will basically find the view object, remove it, create a new instance of vo from the query and executes the query:
findViewObject(DYNAMIC_VO_NAME).remove();
ViewObject vo = createViewObjectFromQueryStmt(DYNAMIC_VO_NAME,newSQL);
vo.executeQuery();
2. In the Client side(controller), override the prepareModel. The overriden method should
- unset the tokenvalidation through : ctx.getBindingContainer().setEnableTokenValidation(false);
- Unbind the rowsetIterator from the dynamicqueryiteratorbinding through : ctx.getBindingContainer(). findIteratorBinding(DYNAMIC_VO_ITER_NAME).bindRowSetIterator(null,false);
- call the method exposed by AM to bind the newSQL to the view object.
- remove the control binding by name. removeControlBinding(ctx,DYNAMIC_VO_RANGE);(basically remove the control binding from the iterator binding list and remove it from the binding container).
removeControlBinding:
—————————
DCBindingContainer bc = ctx.getBindingContainer();
DCControlBinding binding = bc.findCtrlBinding(name);
binding.getDCIteratorBinding().removeValueBinding(binding);
bc.removeControlBinding(binding);
- recreate the control binding and add it to the binding container:addDynamicRangeBinding(ctx,DYNAMIC_VO_RANGE, DYNAMIC_VO_ITER_NAME);
addDynamicRangeBinding
——————————-
DCBindingContainer bc = ctx.getBindingContainer();
JUCtrlRangeBinding dynamicRangeBinding =
new JUCtrlRangeBinding(null,bc.findIteratorBinding(iterName),null);
bc.addControlBinding(bindingName,dynamicRangeBinding);
- Execute super.prepareModel(ctx);
- Reset the tokenvalidation through : ctx.getBindingContainer().setEnableTokenValidation(true);

ADF – Dynamic rendering of UI irrespective of dataobjects

May 22, 2005

The following code in the view layer will render the dataobjects without any change in the view layer even though the view object gets re-constructed in the transaction.

<pre>
<table border=”1″ cellpadding=”2″ cellspacing=”0″>
<tr>
<c:forEach var=”attributeLabel” items=”${bindings.(voname).labelSet”>
<th>
<c:out value=”${attributeLable}” />
</th>
</c:forEach>
</tr>
<c:forEach var=”Row” items=”${bindings.(voname).rangeSet”>
<tr>
<c:forEach var=”attrValue” items=”${Row.attributeValues}” >
<td>
<c:out value=”${attrValue}” />
</td>
</c:forEach>
</tr>
</c:forEach>
</table>
</pre>

Basically the above code makes use of the labelSet and rangeSet properties of the VO object in the bindings and loop through them and print the same.

JBO-30003

May 19, 2005

Getting this error:
oracle.jbo.common.ampool.ApplicationPoolException: JBO-30003: The application pool (model.AppModuleLocal) failed to checkout an application module due to the following exception:
Solution:
- May be the database is down. Bring it up.

Master-Detail design using ADF in uix page

May 17, 2005

In case the view layer is using UIX page, this requirement can even be simplified by dragging the child view object in view link with the option of Master to Detail(many to many). This will automatically take care of synchronization between master and details during navigation.