You are on page 1of 5

9/16/2017 Advanced Table Functionalities in OAF!

| Dibyajyoti Koch:A Blog on Oracle Application

Dibyajyoti Koch:A Blog on Oracle Application

Sharing my learning from an wonderful journey..

Advanced Table Functionalities in OAF!

JUNE 19, 2013 1 COMMENT (HTTPS://IMDJKOCH.WORDPRESS.COM/2013/06/19/ADVANCED-TABLE-


FUNCTIONALITIES-IN-OAF/#COMMENTS)

i
5 Votes

1] Add A Row:

To add an Add a Row bu on, in the advanced table, go to

Advanced Table > Advanced Table Components > Footer > Table Footer > New > Add A Row.

In the Structure pane, select the addTableRow item that is newly created, as shown in the gure above, and use the Property
Inspector to set its following properties (* Required):

ID* specify an identier that uniquely identies the addTableRow item in the page.

Add Rows Label specify text to override the Add Another Row default text that appears in the Add Another Row bu on.

Rows to Add specify the number of rows to add each time a user chooses the Add Another Row bu on. The value for this
property must not be greater than the value set for the Records Displayed property on the advanced table. The default is 1. Note that
this property is valid only if the Insert Rows Automatically property is set to True.

Insert Rows Automatically specify True to indicate rows are to be added automatically when the Add Another Row bu on is
chosen. Specify False if you want to respond to the event in your controller, so that you can, for example, set the primary keys or set
some default row a ributes. Note: The Insert Rows Automatically property is equivalent to the autoInsertion property that was set
in your controller using the setAutoInsertion API for classic tables.

(h ps://imdjkoch.les.wordpress.com/2013/06/add-a-row-in-oaf-advanced-table.jpg)

If you want to handle the Add a Row Event in the Controller, First set Insert Rows Automatically to False and then in controller,
processFormRequest method, call your AM method when user click on the Add a Row in your advanced table AdvTblRN.
https://imdjkoch.wordpress.com/2013/06/19/advanced-table-functionalities-in-oaf/ 1/5
9/16/2017 Advanced Table Functionalities in OAF! | Dibyajyoti Koch:A Blog on Oracle Application
1 if ("addRows".equals(pageContext.getParameter("event")) &&
2 "AdvTblRN".equals(pageContext.getParameter("source")) )
3 {
4 System.out.println("The source is :"+pageContext.getParameter("source"));
5 String p_header_id = (String)pageContext.getTransactionValue("p_tx_header_id");
6 Serializable[] param = {p_header_id};
7 am.invokeMethod("createRow", param);
8 }

In AMImpl wrote the method:

1 public void createRow( String p_header_id)


2 {
3 OAViewObject pervo = getPriceLinesVO1(); // Advanced Table VO
4 if(!pervo.isPreparedForExecution()){
5 pervo.executeQuery();
6 }
7 pervo.setMaxFetchSize(0);
8 pervo.last(); // Go to the last Row of the VO
9 String line_number = pervo.getCurrentRow().getAttribute("LineNumber").toString();
10 String description = pervo.getCurrentRow().getAttribute("Description").toString();
11 Number line_num = new Number(Integer.parseInt(line_number) + 1);
12 pervo.next();
13 Row row = pervo.createRow(); // Create a New Row
14 // Insert the values in the row.
15 Number header_id = new Number(Integer.parseInt(p_header_id));
16 row.setAttribute("HeaderId",header_id);
17 row.setAttribute("LineId",getOADBTransaction().getSequenceValue("XX_PRICE_LINES_SEQ"));
18 row.setAttribute("Description",description);
19 row.setAttribute("LineNumber",line_num);
20 pervo.insertRow(row); // Insert the row in DB
21 row.setNewRowState(Row.STATUS_NEW);
22 getOADBTransaction().commit();
23 System.out.println("Commit Done");
24 }

2] Delete Multiple Rows:

Create a Transient A ribute of type String with any name (say SelectFlag) in the VO. Choose updatable always check bu on.

To add a Delete bu on, in the advanced table, go to

Advanced Table > Advanced Table Components > TableSelection > MultipleSelection > New > SubmitBu on.

In the MultipleSelection, add the view a ribute dened above.

(h ps://imdjkoch.les.wordpress.com/2013/06/multiple-delete-in-oaf-advanced-table.jpg)

In the controller, add logic as below:

1 if (pageContext.getParameter("DelBtn") != null)
https://imdjkoch.wordpress.com/2013/06/19/advanced-table-functionalities-in-oaf/ 2/5
9/16/2017 Advanced Table Functionalities in OAF! | Dibyajyoti Koch:A Blog on Oracle Application
1 if (pageContext.getParameter("DelBtn") != null)
2 {
3 System.out.println("In Delete Button");
4 System.out.println("The source is:"+pageContext.getParameter("source"));
5 OAViewObject linesVO=(OAViewObject)am.findViewObject("PriceLinesVO1");
6 Row[] row=linesVO.getFilteredRows("SelectFlag","Y");
7 System.out.println("Total Rows: "+linesVO.getRowCount());
8 System.out.println("Selected Rows: "+row.length);
9 Row row[] = linesVO.getAllRowsInRange();
10 for (int i=0;i<row.length;i++)
11 {
12 PriceLinesVORowImpl rowi = (PriceLinesVORowImpl) row[i];
13 if (rowi.getSelectFlag()!= null && rowi.getSelectFlag().equals("Y"))
14 {
15 rowi.remove();
16 }
17 }
18 am.getOADBTransaction().commit();
19 }

3] Update Multiple Rows:

Create a Transient A ribute of type String with any name (say SelectFlag) in the VO. Choose updatable always check bu on.

To add a Update bu on, in the advanced table, go to

Advanced Table > Advanced Table Components > TableSelection > MultipleSelection > New > SubmitBu on.

In the MultipleSelection, add the view a ribute dened above.

In the controller, add logic as below:

1 if (pageContext.getParameter("UpdateBtn") != null)
2 {
3 System.out.println("In Update Button");
4 Number user_id = new Number(am.getOADBTransaction().getUserId());
5 String updated_by = user_id.toString();
6 OAViewObject linesVO=(OAViewObject)am.findViewObject("PriceLinesVO1");
7 Row row[] = linesVO.getAllRowsInRange();
8 for (int i=0;i<row.length;i++)
9 {
10 PriceLinesVORowImpl rowi = (PriceLinesVORowImpl) row[i];
11 if (rowi.getSelectFlag()!= null && rowi.getSelectFlag().equals("Y"))
12 {
13 String Bucket_low = rowi.getAttribute("BucketLow").toString();
14 String Bucket_high = rowi.getAttribute("BucketHigh").toString();
15 Number Price = (Number) rowi.getAttribute("Price");
16 Serializable[] param = {rowi.getAttribute("LineId").toString(),rowi.getAttribute("BucketLow"
17 am.invokeMethod("UpdateLinesRecord",param);
18 }
19 }
20 OAViewObject volns = (OAViewObject)am.findViewObject("PriceLinesVO1");
21 volns.clearCache();
22 volns.reset();
23 volns.executeQuery();
24 }

In AM method, you can call PLSQL Procedure to update the data.

1 public void UpdateLinesRecord(String LineId, String BucketLow, String BucketHigh, String Price, String
https://imdjkoch.wordpress.com/2013/06/19/advanced-table-functionalities-in-oaf/ 3/5 upda
9/16/2017 Advanced Table Functionalities in OAF! | Dibyajyoti Koch:A Blog on Oracle Application
1 public void UpdateLinesRecord(String LineId, String BucketLow, String BucketHigh, String Price, String upda
2 {
3 try {
4 CallableStatement cs=this.getOADBTransaction().
5 getJdbcConnection().prepareCall("{call APPS.XXTEST_LINES_PKG.UPDATE_LINES(?,?,?,?,?)}");
6 cs.setString(1,LineId);
7 cs.setString(2,BucketLow);
8 cs.setString(3,BucketHigh);
9 cs.setString(4,Price);
10 cs.setString(5,updated_by);
11 cs.execute();
12 cs.close();
13 }
14 catch(SQLException e) {
15 System.out.println("the exception is"+e);
16 }
17 }

4] Delete or Update Single Row at one time.

If you want to add update and delete icons per rows do the followings:

1. Create Columns in the advanced table say Delete and Update.


2. In the Delete Column, add an image item (deleteicon_enabled.gif). For all image names go to $OA_MEDIA folder.
3. Set Action type to re action.
4. Give any name to Event (Say deleteLine)
5. In the parameter, pass the identier of the row which user wants to delete. You can use SPEL for that.

Example>> p_header_id: ${oa.QotDtlVO1.HeaderId}

In the controller, handle the event deleteLine.

1 if ("deleteLine".equals(pageContext.getParameter(EVENT_PARAM)))
2 {
3 //Handle delete logic here. You can call AM methods which eventually calls PLSQL Procedures to delete the da
4 }

Similarly you can add image link for update also.

Do not forget to reset the VO after operation to reect the new data.

https://imdjkoch.wordpress.com/2013/06/19/advanced-table-functionalities-in-oaf/ 4/5
9/16/2017 Advanced Table Functionalities in OAF! | Dibyajyoti Koch:A Blog on Oracle Application
Advertisements

FILED UNDER OA FRAMEWORK, UNCATEGORIZED TAGGED WITH ADD A ROW IN ADVANCED TABLE, ADVANCED
TABLE IN OAF, DELETE ROWS IN ADVANCED TABLE, INSERT ROWS AUTOMATICALLY, OA FRAMEWORK, OAF,
PROGRAMATICALLY ADD ROWS IN ADVANCED TABLE IN OAF, UPDATE ROWS IN ADVANCED TABLE

One Response to Advanced Table Functionalities in OAF!

jlincoln says:
August 19, 2013 at 2:46 pm
Great information! Thank you for sharing.

Would you have any knowledge of how to update a detail VO a ribute programatically in controller/am methods? My a empts
have all failed. Although the rendered page shows the change the change is not saved to the database. Please see my question at
h ps://forums.oracle.com/thread/2570694.

Thanks again

i
Rate This

Reply

Create a free website or blog at WordPress.com.

https://imdjkoch.wordpress.com/2013/06/19/advanced-table-functionalities-in-oaf/ 5/5

You might also like