Posts

Showing posts from 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 t…

OAF: Parameters

Oracle Application Framework (OAF) can pass parameters between pages and there are three types of parameters
1- Request
The scope of request parameters is finalized after  HTTP request.

Examples of Request Parameters
URL ParametersInput Bean values (Message Text Input, Choice , Check etc) and Hidden Field Values (form values) in case of postEvent triggering bean and the action in case of post.
Request values are accessed using OAPageContext.getParameter() method.

2- Transaction
Transaction has wider scope than Request which finalize with ending of database transaction.
You can create transaction parameter using OAPageContext.putTransactionValue() , ((OADBTransactionImpl)getTransaction()).putValue() .

Get transaction parameter values using OAPageContext.getTransactionValue() , ((OADBTransactionImpl)getTransaction()).getValue()

3- Session
Session has wider scope than Transaction which his life time is until user log out from application.

You can create Session parameter using OAPageContext…

Display Detail Rows as One Column in Master

Image
Sometimes, it is required to display detail rows as a single column in master row.
For example in scott schema you have two tables ( DEPT, EMP) which relation is 1-M .

If required to display Employees names separated by comma  as one column per every DEPTNO, ÷In order to the final output like the following.





The easiest way to get output of previous diagram is the following SQL query.

    SELECT d.deptNo,
           MAX (SUBSTR (SYS_CONNECT_BY_PATH (d.eName, ','), 2)) employees
      FROM (SELECT deptNo,
                   eName,
                   ROW_NUMBER ()
                      OVER (PARTITION BY deptNo ORDER BY deptNo, eName)
                      rnum
              FROM scott.emp) d
START WITH d.rnum = 1
CONNECT BY d.rnum = PRIOR d.rnum + 1 AND PRIOR d.deptNo = d.deptNo
  GROUP BY d.deptNo

Thanks