Posts Tagged ‘view object’

Oralublog - Oralution's Blog

This post will assume that you have, at this point, implemented your Dependent LOV, using ADF Business Components the following;

  • You have View Objects and you have created  View Criterias.
  • Create some LOVs for View Objects attributes.
  • Specifying View Criteria over the View Accessors that retrieves your LOV. (implementing the dependency)

View original post 225 more words

Entity Objects

Entity objects map to single objects in the datasource. In the vast majority of cases, these are tables, views, synonyms, or snapshots in a database. Entity objects handle the posting of changes to the datasource. 

Entity objects provide a hook for implementing your application’s business rules, including:

 

  • Validation logic, which keeps corrupt data from being entered in the database
  • Security logic, which tracks data changes and ensures that only authorized users can see or change data
  • Creation logic, which performs actions (such as prepopulating attributes) for newly created rows
  • Deletion logic, which performs actions when rows are deleted
  • Other logic, such as dynamic calculations and events that trigger when data is modified

View Objects

Oracle ADF view objects are business components that collect data from the datasource, shape that data for use by clients, and allow clients to change that data in the Oracle ADF Business Components cache. For example, a view object can gather all the information needed to:

  • Populate a single table element in a form
  • Create and process an insert or edit form
  • Create an LOV for populating a dropdown list

ViewObject decribes how the application will view and update data. A view object may be entity based or non-entity based. In the former case, the view object consists of one or more entity bases. The first one of these is referred to as the primary entity base. The rest are called secondary entity bases. An entity based view object maps its attribute (view attributes) to attributes in the entities (entity attributes). An entity based view object may map all its entity attributes or only some of them.

A non-entity based view object is one where it does not have any entity base. All its attributes are view level attributes. In this case only READ operation is allowed from the VO.

http://docs.oracle.com/cd/B14099_19/web.1012/b14022/oracle/jbo/ViewObject.html

http://download.oracle.com/otn_hosted_doc/jdeveloper/1012/bc4j/intro/bc_avo.html

There are very few references about this so I thought to post it here.

To get the query you have to override the executeQueryForCollection() in your ViewObjectImpl. Before calling super(), you can get/print out the result of getQuery() method.

protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams) {
getQueryParameters();
q = getQuery();
System.out.println(“SQL = ” + q);
if (params != null) {
for (int i = 0; i < params.length; i++) {
Class cls = params[i].getClass();
System.out.println(“Class is ” + cls.getName());
System.out.println(“Query param ” + i + ” ” + String.valueOf(params[i]));
}
}
super.executeQueryForCollection(qc, params, noUserParams);
}

There are several different methods on getting ViewObjects in ADF programmatically. It is possible to create a method within the Application Module Impl or your view object Impl class and then call that method through your managed bean or you can even call it directly within your managed bean but the first method is suitable.

1- Within the application module

ViewObjectImpl vo = getYourViewObject();
ViewCriteria vc = vo.getViewCriteria(“MyCriteria”);
vo.applyViewCriteria(vc);
vo.setNamedWhereClauseParam(“some_param”, anyParam);
vo.executeQuery();
Row row = vo.getCurrentRow();

2- Within your View Object

ViewCriteria vc = getViewCriteria(“MyCriteria”);
applyViewCriteria(vc);
setNamedWhereClauseParam(“some_param”, anyParam);
executeQuery();

3- Within your Managed Bean

AppModuleImpl am = new AppModuleImpl();
ViewObjectImpl vo = am.getYourViewObject();
ViewCriteria vc = getViewCriteria(“MyCriteria”);
vo.applyViewCriteria(vc);
vo.setNamedWhereClauseParam(“some_param”, anyParam);
vo.executeQuery();