Showing posts with label Business Component. Show all posts
Showing posts with label Business Component. Show all posts

03 June, 2015

ADF ::: Creating View Criteria Programmatically

We can add view criteria programmatically at run-time to ViewObject. So that we not only depend on Design View Criteria.

The following is an example used to create View Criteria in Application Module Impl

ViewObject empVO= this.findViewObject("EmpVO");
ViewCriteria vc = empVO.createViewCriteria();
ViewCriteriaRow vcRow = vc.createViewCriteriaRow();

// ViewCriteriaRow attribute name is case-sensitive.
// ViewCriteriaRow attribute value requires operator and value.
// Note also single-quotes around string value.
ViewCriteriaItem enameItem= vcRow.ensureCriteriaItem("Ename");
enameItem.setOperator("=");
enameItem.getValues().get(0).setValue("Mahmoud Elsayed");
vc.add(vcRow);

empVO.applyViewCriteria(vc);

 

Thanks

19 May, 2015

OAF : NewRowState of New Rows

By default, entity objects are created with the row state of STATUS_NEW, and BC4J adds them to its validation.  In this case, any event that triggers a validation or database post sequence includes these entity objects.
As per OAF Model Coding Standards, always circumvent this behavior by explicitly calling the setNewRowState(STATUS_INITIALIZED) method on its containing ViewRowImpl immediately after you insert the newly created row. This sets the state of any associated entity objects to STATUS_INITIALIZED.
When you do this, BC4J removes the corresponding entity objects from the transaction and validation listener lists, so they will not be validated or posted to the database. As soon as the user makes a change (an attribute "setter" is called), the entity object's state changes to STATUS_NEW, and BC4J returns it to the validation/post lists. You can also call setNewRowState(STATUS_NEW) on the ViewRowImpl to change the state manually at any time.


Let's trace some scenarios 
Scenario 1: Row has been modified in the UI before submit. Row State could be anything. 
  • The RowState becomes New.
  • ValidateEntity will get called before processFormRequest().
Scenario 2: Called row.setNewRowState(Row.STATUS_NEW) after inserting a new row. Row has not been modified from UI. 
 
ValidateEntity will not get called before processFormRequest() but will get called on commit and postChanges.
 
Scenario 3: Called row.setNewRowState(Row.STATUS_INITIALIZED) after inserting a new row. Row has not been modified from UI.
  • ValidateEntity will not get called before processFormRequest() or on commit or postChanges.
  • The Row will be ignored by the Framework and removed from the Cache.
  • Even the mandatory fields in the Entity Object are not checked.
Please make sure setting the row state (Row.setNewRowState) should be done after adding the row to VO as recommended in the OAF Standard.

Thanks

20 April, 2015

ADF & OAF ::: Missing IN or OUT parameter

If the bind variable required property wrongly defined into View Object, then it will cause following exception
"java.sql.SQLException: Missing IN or OUT parameter at index:: 1 "

To avoid this exception, you have to keep in mind when you are creating bind variable.
 1- If you are directly passing the bind variable in view object main query then in this case bind variable require property should be selected.

2- If you are using bind variable in view criteria only  then in this case the bind variable require property should not be selected.

Thanks

25 September, 2013

OAF Overview

This post will explains some terminologies that is used in Oracle Application Framework (OAF).

Entity Object - business component entity objects maps to database table or view that allow DML operations and that used to cache data result set and perform validation before post changes to database. 

Association Object - business component association objects implement the relationships between different entity objects and can mapped to database referential integrity constraint or non existing referential integrity constraint and this case constrain will be validated in OAF but not in database.

View Object - business component view objects are used to display data in UI pages and it can be based on
1- Entity Object or many entity objects and this case it supports DML operations.
2- SQL queries  : that's doesn't support DML operations
3- Static : Programmer create structure of view object attributes and can add static data also.
4- Programmatic : Programmer write code at runtime to get dynamic data of view object.

View Link - Establishes a master/detail relationship between different view objects and can be in more depth master/detail/detail/....

Validation View Object - A view object created exclusively for the purpose of performing light-weight SQL validation on behalf of entity objects or their experts.

Application Module - An application module is a container for related BC4J objects. The AM is connected to the database, and is responsible for the commit and rollback of a transaction.

Validation Application Module - An application module created exclusively for the purpose of grouping and providing transaction context to related validation view objects. Typically, a standalone entity object or the top-level entity object in a composition would have an associated validation application module.

Root Application Module - Each pageLayout region in an OA Framework application is associated with a "root" application module which groups related services and establishes the transaction context.

This transaction context can be shared by multiple pages if they all reference the same root application module, and instruct the framework to retain this application module (not return it to the pool) when navigating from page to page within the transaction task.

Entity Expert - A special singleton class registered with an entity object (EO) that performs operations on behalf of the EO.

Controller - The controller is the java code in charge of loading a page when we call it. It is also in charge of handling an event on a page, like a click on a button, or the call of a List Of Values.
 

Attribute Set - Bundles of region or item properties that can be reused either as is or with modifications. For example, all buttons sharing the same attribute set would have the same label and Alt text. 


Thanks

21 August, 2013

ADF : Change View Criteria Columns at Runtime


When creating view criteria related to view object, then all querable attributes are displayed in view criteria by default.
So I want to change the properties of this attributes at run time pragmatically to display or hide specific attributes in view criteria.

I developed the following method for this purpose, You can add this method to ViewObjectImpl class.

I pass attribute name and a Boolean value to determine display in view criteria or no.

 public void setQuerable(String attributeName, Boolean isQuerable) {  
   
     int indx = this.getAttributeIndexOf(attributeName);  
   
     ViewAttributeDefImpl attr = (ViewAttributeDefImpl)this.getAttributeDef(indx);  
   
     attr.setQueriable(isQuerable);  
   
   }  


Thanks

ADF : Scope Variables

Oracle ADF uses many variables and each variable has a scope. There are five scopes in ADF (Application, Request, Session, View and PageFl...