Monday, June 18, 2012

ADF : MDS-00013: no metadata found for metadata object

Problem : ADF : MDS-00013: no metadata found for metadata object
Solution : Make sure when you refactor Model project especially package names, Jdeveloper ignores to refactor the updated package names in Model.jpx and some other xml files, so you have to manually correct those package names, Remove the EAR file from JDeveloper\system11.1.1.4.37.59.23\o.j2ee\drs folder, Clean All, Make All and run your application. These steps resolved my problem.


Thursday, April 12, 2012

Save/Delete Master Detail Data using ADF 11g

Requirement # Save both Master and Detail data in a single transaction without throwing any error.
Solution : Open Entity association.xml ->Relationships->Behavior->Check 'Composition association' option
Requirement # All the child related data should get deleted from database upon deleting the parent record from database table
Solution:Open Entity association.xml ->Relationships->Behavior->Check 'Composition association' option, check ' Implement Cascade Delete'

Usage of overriding postChanges() in EntityImpl class.

push the middle-tier changes to the database without actually committing.
Scenario # You have a Master and detail tables and there is no foregin key relation ship, You may have to get the Master Primary key and set to child Entity, DBTransaction.commit() should first save the master record into Database then upon successful saving master recrod it should save the child recrod. So that dbTransaction.commit() shound't throw any 'Key Not found' related exceptions while saving both master and detail data in a single trascation.
Solution : postChange() override this method in EntityImpl class, what this will do is Push the middle-tier database related changes to database without actually performing commit, so that when child record gets inserted into database without any errors.
Refer below for more information http://docs.oracle.com/cd/B14099_19/web.1012/b14022/oracle/jbo/server/EntityImpl.html#postChanges_oracle_jbo_server_TransactionEvent_ Override below two methods in both master and child EOImpl classes
MasterEOImpl.java
public void postChanges(TransactionEvent TransactionEvent) {
if (getPostState() == STATUS_NEW) {
mNewServiceProviderCostsBeforePost = (RowSet) getServiceProviderCostEO();
}
super.postChanges(TransactionEvent);
}
ChildEOImpl.java
public void postChanges(TransactionEvent e)
{
if (getPostState() == STATUS_NEW getPostState() == STATUS_MODIFIED) {
MasterEOImpl masterEO= getMasterEO();
if (masterEO!= null) {
if (masterEO.getPostState() == STATUS_NEW) {
masterEO.postChanges(e);
}
}
}
super.postChanges(e);
}
and also override below methods in MasterEOImpl.java
refreshFKInNewContainees() - Iterate the child RowSet and set the primary key then close the rowSetIterator.
handlePostChangesError() - Override this method , If any error happens this will get invoked and close row set iterator.






Monday, April 9, 2012

How to Configure AM Pool size

By default AM pool size is '25', So all the AM instances can be shared across multiple sessions, If you want to see how an UI application behaves in Prod base environments when number of users logged more than expected, You can make the AM pool size to as minimum as and access the applications in multiple browsers, and AM instances can be shared across multiple sessions and you will see how application performs.

Right click on UI Project ->Project Properties-> Run/Debug/Profile->Select Default and click on Edit -> Enter the below -D command and click on ok


-Djbo.ampool.minavailablesize=1 -Djbo.recyclethreshold=1 -Djbo.failover=true

Thursday, March 15, 2012

How to get selected rows from View object in an Application Module based on specific value on an attribute

I have noticed many times while developing ADF applications, Most of us having a common requirement for instance - How to get selected rows from View object in an Application Module based on specific value on an attribute ?

The view object might be having 50K rows displayed on screen out of it user could have selected less number of rows. Instead of iterating all the rows to determine 2 selected rows out of it, We can always use getFilteredRows() method on VO and get the array of selected rows.

Row[] selRowArr = vo.getFilteredRows("RowChkFlg", Boolean.TRUE);

In this example, RowChkFlg is one of the boolean attribute dragged onto the screen and allows to select row.

Monday, March 5, 2012

How to get a specific component in Backing bean without binding to backing bean using ADF ?

Below snippet provides a way to get a selected ADF UI RichComponent in backing bean without actually binding the component to a backing bean or managed bean. This will help you to avoid too many bindings in any managed or backing bean

private static UIComponent findUIComponent(UIComponent pRootComponentString pComponentId)
{
if (pComponentId.equals(pRootComponent.getId()))
return pRootComponent;
UIComponent kid = null;

UIComponent result = null;
Iterator kids = pRootComponent.getFacetsAndChildren();
while (kids.hasNext() && (result == null))
{
kid = (UIComponent) kids.next();
if (pComponentId.equals(kid.getId()))
{
result = kid;
break;
}
result = findComponent(kid, pComponentId);
if (result != null)
{
break;
}
}
return result;
}

How to get a Value of SelectOneChoice Component in Backing bean?

There is a no way to get the short code of selected Value for component using ADF framework in Managed bean or backing bean, It always returns 'Index' instead actual value, This is a bug with ADF framework. The easy workaround to achieve this functionality is as below

// This will set the new Index value 

JSFUtils.setExpressionValue("#{bindings.FuelSrchrgRateUom.inputValue}",
                                valueChangeEvent.getNewValue());
// Get thhe value associated to new Index which already set in above step
String shortCd= (String) JSFUtils.resolveExpression("# {bindings.FuelSrchrgRateUom.inputValue} ");Here "bindings.ExecuteWithParams_BindComponent" is defined in Page def binding.

public static Object resolveExpression(String expression)
{
FacesContext fc = getFacesContext();
Application application = fc.getApplication();
ELContext elCtx = fc.getELContext();
ExpressionFactory elFact = application.getExpressionFactory();
ValueExpression valExp = elFact.createValueExpression(elCtx, expression, Object.class);
return valExp.getValue(elCtx);
}


Alternative way is