OAF Partial Page Rendering on Table and Form (PPR)
Hello,
In this tutorial, I will post about partial page rendering on OAF forms and tables.
1. Run the following database setup query in order to create database objects for using in the tutorial.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
create table xxntc.xx_ppr_single ( id number primary key, attr1 varchar2(100), attr2 varchar2(100), creation_date date, created_by number, last_update_date date, last_updated_by number, last_update_login number ); create public synonym xx_ppr_single for xxntc.xx_ppr_single; create sequence xxntc.xx_ppr_single_s start with 1; create table xxntc.xx_ppr_table ( id number primary key, attr1 varchar2(100), attr2 varchar2(100), creation_date date, created_by number, last_update_date date, last_updated_by number, last_update_login number ); create public synonym xx_ppr_table for xxntc.xx_ppr_table; create sequence xxntc.xx_ppr_table_s start with 1; begin for i in 1..5 loop insert into xxntc.xx_ppr_table values (xxntc.xx_ppr_table_s.nextval, dbms_random.string('A', 5), dbms_random.string('A', 5), sysdate, -1, sysdate, -1, -1); end loop; commit; end; |
2. Open a JDeveloper which has already prepared for initial setup. Right Click to your project and click New. Go To Business Tier-> ADF Business Componenets -> Business Components from Tables and click Ok button.
3. Do the following steps in order to generate BC4J objects.
4. Final structure for BC4J model:
5. Overwrite create method for XxPprSingleEO ve XxPprTableEO Entity Objects.
PPR For Single Row Forms
This section will be about PPR on Single Row Forms. Partial View Objects are used in order to provide dynamic interface for OAF pages. There are four properties that can be changed by dynamically. These 4 properties are:
- Rendered (true or false): Dynamic Visibility
- Disabled (true or false): Dynamic disabling
- Read-Only (true or false): Dynamically making items read-only.
- Required (yes, no, uiOnly, validaterOnly): Dynamically making items required.
Do the following steps.
1. Create a new PVO in server package. Partial View Objects are neither generated from a SQL Query not Entity Object. Partial View Objects should have two attributes which are created declaratively or programmatically.
These attributes are:
- Key Attribute: Number
- Property Attribute: Depending on property it can be String or Boolean. If it is required property, then String must be used otherwise Boolean must be used.
Partial View Objects must be initialized on process request method and must have at least&most one row in it. However that initially created one row property attribute may be change depending on the actions that trigger partial page rendering. In addition, property attributes will be used with SPEL language on the item properties that we want to dynamically change.
2. Add partial view object into the application module.
3. Create a new OAF page and pageLayoutRegion controller class.
4. Edit pageLayoutRegion properties with the following information:
ıd | window tıtle | tıtle | AM Defınıtıon |
---|---|---|---|
PageLayoutRN | PPR Example | PPR Example | xxntc.oracle.apps.per.ppr.server.XxPprAM |
5. We will be using one attribute as a trigger for the other attribute. Therefore, it is much more make sense to use a combo box. In order to provide values for combo box, create a new Read-Only View object and add it into application module.
SQL Query:
1 2 3 4 5 |
select 'DISABLED' as value from dual union select 'NOT DISABLED' as value from dual |
6. Create a new defaultSingleColumn form region under pageLayoutRegion.
7. Edit Attr1 and Attr2 properties with the following information:
ıtem Style | Pıcklıst Vıew Defınıtıon | Pıcklıst Dısplay Attrıbute | Pıcklıst Value Attrıbute | Actıon Type | Event |
---|---|---|---|---|---|
messageChoice | xxntc.oracle.apps.per.ppr.poplist.server.XxPprAttr1LovVO | Value | Value | firePartialAction | onAttr1Change |
Dısabled |
---|
${oa.XxPprSingleAttr2PVO1.Attr2Disabled} |
8. Apply the following code changes in java files.
XxPprSingleEOImpl.java
1 2 3 4 5 6 7 8 |
public void create(AttributeList attributeList) { super.create(attributeList); OADBTransactionImpl transaction = (OADBTransactionImpl)getOADBTransaction(); Number Id = transaction.getSequenceValue("XXNTC.XX_PPR_SINGLE_S"); setId(Id); } |
XxPprPGCO.java
1 2 3 4 5 6 7 8 9 10 11 |
public void processRequest(OAPageContext pageContext, OAWebBean webBean) { super.processRequest(pageContext, webBean); OAApplicationModule am = pageContext.getApplicationModule(webBean); if (!pageContext.isFormSubmission()) { am.invokeMethod("createSingleRow"); } am.invokeMethod("initPvo"); } |
1 2 3 4 5 6 7 8 9 10 |
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { super.processFormRequest(pageContext, webBean); OAApplicationModule am = pageContext.getApplicationModule(webBean); if ("onAttr1Change".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM))) { am.invokeMethod("handeAttr1ChangeEvent"); } } |
XxPprAMImpl.java
1 2 3 4 5 6 7 8 9 10 11 |
public void createSingleRow() { XxPprSingleEOVOImpl vo = getXxPprSingleEOVO1(); if (!vo.isPreparedForExecution()) { vo.executeQuery(); } Row row = vo.createRow(); vo.insertRow(row); row.setNewRowState(Row.STATUS_INITIALIZED); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
public void initPvo() { OAViewObject pvo = (OAViewObject)findViewObject("XxPprSingleAttr2PVO1"); if (pvo != null) { if (pvo.getFetchedRowCount() == 0) { pvo.setMaxFetchSize(0); pvo.executeQuery(); Row row = pvo.createRow(); pvo.insertRow(row); row = (OARow)pvo.first(); row.setAttribute("RowKey", new Number(1)); } handeAttr1ChangeEvent(); } else { throw new OAException("Error"); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
public void handeAttr1ChangeEvent() { OAViewObject vo = (OAViewObject)findViewObject("XxPprSingleAttr2PVO1"); OARow row = (OARow)vo.first(); OAViewObject singleVo = (OAViewObject)findViewObject("XxPprSingleEOVO1"); OARow singleRow = (OARow)singleVo.getCurrentRow(); if (singleRow.getAttribute("Attr1") != null) { String value = (String)singleRow.getAttribute("Attr1"); if ("DISABLED".equals(value)) { row.setAttribute("Attr2Disabled", Boolean.TRUE); } else if ("NOT DISABLED".equals(value)) { row.setAttribute("Attr2Disabled", Boolean.FALSE); } else { row.setAttribute("Attr2Disabled", Boolean.TRUE); } } else { row.setAttribute("Attr2Disabled", Boolean.TRUE); } } |
9. Run the page and test it.
PPR for Tables
1. Create a new page and pageLayoutRegion Controller class.
2. Edit pageLayoutRegion properties with the following information.
ıd | wındow tıtle | tıtle | AM Defınıtıon |
---|---|---|---|
PageLayoutRN | Table PPR | Table PPR | xxntc.oracle.apps.per.ppr.server.XxPprAM |
3. Edit XxPprTableEOVO view object and move on SQL Statement section. Check “Expert Mode” check box and modify the SQL by adding two null columns as SELECTED and ATTR1_DISABLED. Move on to the Attributes section and change Attr1Disabled attribute type as Boolean. Also make sure that both attributes are updatable always.
SQL Query:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
SELECT XxPprTableEO.ID, XxPprTableEO.ATTR1, XxPprTableEO.ATTR2, XxPprTableEO.CREATION_DATE, XxPprTableEO.CREATED_BY, XxPprTableEO.LAST_UPDATE_DATE, XxPprTableEO.LAST_UPDATED_BY, XxPprTableEO.LAST_UPDATE_LOGIN, null SELECTED, null ATTR1_DISABLED FROM XXNTC.XX_PPR_TABLE XxPprTableEO |
4. Add new table region using wizard with the following steps.
5. Make following modifications for Selected Check Box item.
Inıtıal Value | Checked Value | Unchecked Value | Actıon Type | Event |
---|---|---|---|---|
N | Y | N | firePartialAction | onCheckBoxChange |
6. Apply the following code changes in java files.
XxPprTableEOImpl.java
1 2 3 4 5 6 7 8 |
public void create(AttributeList attributeList) { super.create(attributeList); OADBTransactionImpl transaction = (OADBTransactionImpl)getOADBTransaction(); Number Id = transaction.getSequenceValue("XXNTC.XX_PPR_TABLE_S"); setId(Id); } |
XxPprTablePGCO.java
1 2 3 4 5 6 7 8 9 10 |
public void processRequest(OAPageContext pageContext, OAWebBean webBean) { super.processRequest(pageContext, webBean); OAApplicationModule am = pageContext.getApplicationModule(webBean); am.invokeMethod("executeTableVO"); OAMessageTextInputBean Attr1Bean = (OAMessageTextInputBean)webBean.findChildRecursive("Attr1"); Attr1Bean.setAttributeValue(OAWebBeanConstants.DISABLED_ATTR, new OADataBoundValueViewObject(Attr1Bean, "Attr1Disabled", "XxPprTableEOVO1", false)); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { super.processFormRequest(pageContext, webBean); OAApplicationModule am = pageContext.getApplicationModule(webBean); if ("onCheckBoxChange".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM))) { String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE); Row currentRow = am.findRowByRef(rowReference); String selected = (String)currentRow.getAttribute("Selected"); if ("Y".equals(selected)) { currentRow.setAttribute("Attr1Disabled", Boolean.TRUE); } else { currentRow.setAttribute("Attr1Disabled", Boolean.FALSE); } } } |
XxPprAMImpl.java
1 2 3 4 5 6 7 8 9 |
public void executeTableVO() { XxPprTableEOVOImpl vo = getXxPprTableEOVO1(); if (vo == null) { throw new OAException("Error!"); } vo.executeQuery(); } |
7. Run the page and test it. Attr1 should be row-level disabled or enabled depending on Selected check box.
Regards 🙂
Anıl senin blog olmasa benim projeler bitmiyecek la! Haha table tarafını direk kopyaladım, çalışıyor.
Böyle Kerem gibi beleşçi arkadaşları kınıyorum. Bu faydalı paylaşım için teşekkürler Anıl.
Hi,
Sorry to bother you.
I could able to resolve the number formula issue, but i have to format these numbers.
i.e. say
the data is as below
emp salary
———————–
abc 10000
efg 20000
xyz 30000
this i could able to display, but i need to display as below
emp salary
———————–
abc 10,000.00
efg 20,000.00
xyz 30,000.00
i had a page with the data in advanced table region with a view object EmpVO and VO column names as emp and salary and advance table column id’s as empName and sal.
and the salary is of oracle.jbo.domain.Number type (not int/float/double…).
I apologize if I am asking too much.
Thanks in advance,
Rhea.
Try This:
Formatter formatter = new OADecimalValidater("#.##0,00","#.##0,00");
bean.setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, formatter);
Great Work! Really Helped a lot ! Thank You Very Much!
You are the best, thanks