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.
Thursday, October 13, 2005
ADF:Setting of who columns(Audit columns) in the Entity Object
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.
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.
Subscribe to:
Posts (Atom)