Custom base classes are used to customize functionalities of business component objects and to write reusable code in application. We must configure base classes before creating business components like Application Module, Entity, View Object and etc.
For Configure business components Right Click on the Model project and go to Project Properties and expand Business Components and click on Base classes. Sometimes Browse button will not appear, at that time we need to add the connection to the application through New --> ADF Business components ---> Business Components from tables --> add connection and click finish, it will create Model.jpx file(Don't create any EO, VO or AM).
Custom ApplicationModuleImpl :
import oracle.jbo.server.ApplicationModuleImpl;
public class FMWAppModuleImpl extends ApplicationModuleImpl {
public FMWAppModuleImpl() {
super();
}
}
Custom EntityImpl :
import oracle.jbo.server.EntityImpl;
public class FMWEOImpl extends EntityImpl {
public FMWEOImpl() {
super();
}
}
Custom ViewObjectImpl :
import oracle.jbo.server.ViewObjectImpl;
public class FMWVOImpl extends ViewObjectImpl {
public FMWVOImpl() {
super();
}
}
Custom ViewRowImpl :
import oracle.jbo.server.ViewRowImpl;
public class FMWVORowImpl extends ViewRowImpl {
public FMWVORowImpl() {
super();
}
}
Why Custom Base classes :
It is a good practice to configure custom base classes to ADF application. Custom base classes simplify the reusable code. In below code works as contains instead of start string in table string filter.
public class FMWVOImpl extends ViewObjectImpl {
public FMWVOImpl() {
super();
}
/**
* For filter works like contains
**/
public String getCriteriaItemClause(ViewCriteriaItem viewCriteriaItem) {
if (viewCriteriaItem.getAttributeDef().getJavaType().getName().equals("java.lang.String")) {
if (!(viewCriteriaItem.getValue() != null && viewCriteriaItem.getValue().toString().startsWith(":")))
viewCriteriaItem.setValue("%" + viewCriteriaItem.getValue() + "%");
}
viewCriteriaItem.setUpperColumns(true);
return super.getCriteriaItemClause(viewCriteriaItem);
}
}
For using this functionality we just need to generate a class for view object which we are using in af:table data.