Sie sind auf Seite 1von 9

Topics for Today:

-----------------
- Delete
- PPR
- Lets see :-)
-------------------------------------------------------------
Delete Exercise
----------------
We will enhance on the Search Page.
We shall add a - trashcan icon for DELETE
SWITCHER - Switchers are used to display alternative content in a column based o
n the conditions. Switchers can only be used in tables.
Employee Name |... | Delete (Its a switcher column)
-----------------------------------------------------
ABC |*|*| - delete enabled (deleteenabled_icon.gif)
XYZ ||| - delete disabled (deletedisabled_icon.gif)
whether to display the disabled or the enabled icon is dependent on the fact whe
ther EMPLOYEE has got an end date populated in the table record or not.
If END DATE is populated - DELETE icon be ENABLED
If END DATE is not populated - DELETE icon be DISABLED
All icons are stored under a directory - $OA_MEDIA
SPEL EXPRESSIONS:
Simplest Possible Expression Language
${oa.<VOName>.<VOAttributeName>}
DIALOG PAGE
In OAF, Dialog pages are used to act as a WARNING PAGE that prompts the user to
go ahead or cancel the current transaction.
*********************************************************************
Recap:
-------
1. To enhance the EO based VO, so as to include the VO attribute for SWITCHER (w
hich we shall add to the Results table later)
SELECT EmployeeEO.EMPLOYEE_ID,
EmployeeEO.FIRST_NAME,
EmployeeEO.LAST_NAME,
EmployeeEO.FULL_NAME AS EMPLOYEE_NAME,
EmployeeEO.EMAIL_ADDRESS AS EMPLOYEE_EMAIL,
EmployeeEO.POSITION_CODE,
ManagerEO.EMPLOYEE_ID AS MANAGER_ID,
ManagerEO.FULL_NAME AS MANAGER_NAME,
flv.meaning AS POSITION_DISPLAY,
-- This is what we added
decode(nvl(to_char(EmployeeEO.END_DATE),'N'),'N','DeleteDisabled','DeleteEnabled
') AS DELETE_SWITCHER
-- End of Addition
FROM FWK_TBX_EMPLOYEES EmployeeEO, FWK_TBX_EMPLOYEES ManagerEO,
fwk_tbx_lookup_codes_vl flv
WHERE EmployeeEO.MANAGER_ID = ManagerEO.EMPLOYEE_ID(+)
AND EmployeeEO.POSITION_CODE = flv.LOOKUP_CODE
AND flv.lookup_type = 'FWK_TBX_POSITIONS'
2. Right Click on Results Table on Search Page - Add a new SWITCHER
-> ID: DeleteSwitcher
-> Prompt: Delete Employee
-> View Instance: EmployeeSearchVO
-> View Attribute: DeleteSwitcher
-> An item of type CASE is added by default under the switcher
-> Right Click on CASE, add a new ITEM, set the following properties:
ID: DeleteEnabled [Exactly similar to one Decode statement retur
ned values in the VO for switcher].
Style: Image
ImageURI: deleteicon_enabled.gif
Additional Text: Click to delete Employee
-> Right Click on Switcher, add another case.
-> Right Click on CASE, add a new ITEM, set the following properties:
ID: Deletedisabled [Exactly similar to one Decode statement retu
rned values in the VO for switcher].
Style: Image
ImageURI: deleteicon_disabled.gif
Additional Text: Delete Disabled for this employee.
3. Enable Action on DELETE ENABLED ICON
-> Select DeleteEnabled item in Structure window.
-> In the property inspector, set CLIENT ACTION -> Action type: Fire Act
ion
-> Change the Event Name from UPDATE to something like, 'deleteE
mployeeEvent'
-> Parameters:
Name: deletePersonId
Value: ${oa.EmployeesSearchVO1.EmployeeId}
4. Add the following code to the CO in pfr():
import oracle.apps.fnd.framework.webui.OADialogPage;
import java.util.Hashtable;
if((pageContext.getParameter("event") != null) &&
(pageContext.getParameter("event").equals("deleteEmployeeEvent")))
{
String personIdForDelete = (String)pageContext.getParameter("deletePer
sonId");
//throw new OAException("Delete Action Caught ! "+personIdForDelete);
// Code for DialogPage
// On press of YES - the CONFIRM DELETE code will fire.
// 1. Initializing Dialog Page with the message
OAException dialogMessage = new OAException("Do You Want to Confirm the
Delete of the employee?");
OADialogPage dialogPage = new OADialogPage(OAException.WARNING, dialogM
essage, null, "", "");
// 2. Setting Prompts on YES and NO button + Associating Events with bu
ttons
String promptYes = "May: Yes";
String promptNo = "May: No";

// Event Name
dialogPage.setOkButtonItemName("confirmDeleteAction");
// The following 3 steps ensure that YES and NO buttons on the Dialog P
age
// are converted to SUBMIT Buttons, which fire actions.
dialogPage.setOkButtonToPost(true);
dialogPage.setNoButtonToPost(true);
dialogPage.setPostToCallingPage(true);
dialogPage.setOkButtonLabel(promptYes);
dialogPage.setNoButtonLabel(promptNo);
// 3. Pass any parameters from the base page to the dialog page and re-
direct to the dialog page.
Hashtable dialogPageParams = new Hashtable(1);
dialogPageParams.put("eid", personIdForDelete);
dialogPage.setFormParameters(dialogPageParams);

pageContext.redirectToDialogPage(dialogPage);
}
if(pageContext.getParameter("confirmDeleteAction") != null)
{
String personIdfromHashTable = (String)pageContext.getParameter("eid");
Serializable[] params = {personIdfromHashTable};
OAApplicationModule am = (OAApplicationModule)pageContext.getApplicati
onModule(webBean);
am.invokeMethod("deleteEmployee", params);
throw new OAException("Employee Successfully Deleted.", OAException.CO
NFIRMATION);
}
5. Add the following code in the AM:
public void deleteEmployee(String personId)
{
EmployeesSearchVOImpl vo = getEmployeesSearchVO1();
int rowCount = vo.getFetchedRowCount();
System.out.println("RowCount: "+rowCount);
RowSetIterator deleteIterator = vo.createRowSetIterator("XXXX");
deleteIterator.setRangeStart(0);
deleteIterator.setRangeSize(rowCount);
System.out.println("## Person Id from Page: "+personId);
for(int i = 0; i<rowCount ; i++)
{
EmployeesSearchVORowImpl row = (EmployeesSearchVORowImpl)vo.getRowAtRan
geIndex(i);
String perIdfromVO = row.getEmployeeId().toString();
System.out.println("## Person Id from VO: "+perIdfromVO);
if(perIdfromVO.equals(personId))
{
System.out.println("## MATCH Person Id from VO: "+perIdfromVO);
System.out.println("## MATCH Person Id from Page: "+personId);
System.out.println("## Both person Ids are equal");
row.remove();
getTransaction().commit();
break;
}
}
deleteIterator.closeRowSetIterator();
}
********************************************************************************
*
Partial Page Rendering (PPR)
-------------------------------------
fireAction - we set this action on delete icon.
firePartialAction - we can set this action on items as well.
Based on a user action on some item, on which "Partial Fire Action" is enabled -

An item on which Partial Fire Action is enabled.
A set of item(s), which is affected by that partial action.
Remaining items on the page remain unaffected.
When PPR occurs, the entire page is refreshed, the PPR action takes place ONLY o
n the affected item(s), the rest if the items on the page continue to hold their
values.
-----------------------
On fire of a particular action - called as - firePartialAction (In Delete - we
had fired - fireAction), only a portion of the page refreshes - The rest of the
page remains the same and retains the value.
When you select an attribute for which PARTIAL ACTION is enabled or set: Only a
portion of the page would refresh, and the attribute which is to be affected by
PPR is set/reset/whatever, remaining values on the page remain unaffected.
PPR is a means by which designated parts of a page, rather than the whole page,
is refreshed when the user performs certain actions.
Developers can:
- Configure the selection of a poplist (drop down) to cause other fields to rend
er, be updateable, be required et cetera.
- Configure the value change in a text field to cause other fields to render, be
updateable, be required et cetera.
- Configure the selection of a master's table record to automatically query and
display child rows in a detail table.
Mostly, developers try to control these properties:
* Rendered
* Read Only
* Disabled
* Required
PPR is coded using a Application 'Properties View Object' (PVO)
PVO always has 1 row.
Its columns are all transient attributes - Transient attributes are VO columns w
hich are not a part of the VO select query.
Columns are -
- ROWKEY (NUMBER), Key Attribute
- XXXXXX (BOOLEAN): This value is set, which is then used to control other field
s.
PVO always has only one row with rowkey = 1
So, on a page which has PPR to deal with, in the processRequest of the page's co
ntroller, we have to write code to initialise the PVO.
There is a standard code, just cut-copy-paste the same code whenever u wish to i
nitialize the PVO.
--
We can declaratively enable PPR on (and more):
- link
- messageCheckBox
- messageChoice
- button
- radioButton
- submitButton
- messageTextInput
* Profile Option - FND: Disable Partial Page Rendering - NO (If PPR is to happen
.)
* User's browser must support iFrame (IE 5.5+, Netscape 6+ and Mozilla)
--------------------------------------------------------------------------------
-----
Create Employee Page
---------------------
Position Drop Down - Buyer, Vice President, President, Group Manager.
Manager - .....
If we select PRESIDENT in the drop down - the Manager field should be rendered O
FF i.e. Hidden.
-> pr() -> initPVO() --> sets RowKey = 1 in PVO, calls renderManagerItem()
-> pfr() -> renderManagerItem() -> PPR results on the page.
REQUIRED true for FNAME, LNAME, SALARY.
Position Code - PPR - Page refreshed -
Hence, for position code item - I set Disable Client side Validation = TRUE.
Recap
------
1. Create the PVO
- Right Click on the Project, create new View Object
- Name: EmployeePVO
- Add 2 transient Attributes:
1. Name = RowKey, Type = Number, Key Attribute, Always Updateabl
e
2. Name = xxManagerRender, Type = Boolean, Always Updateable
- Generate both the java files.
2. Add the PVO to the page AM.
3. Enable Partial Action on Position Drop down.
-> In the property inspector, set CLIENT ACTION -> Action type: Fire par
tial Action
-> Change the Event Name from UPDATE to something like, 'hideMan
agerItem'
-> Set Disable Server Side Validation and Disable Client Side Validation
to TRUE.
4. Set the Rendered Property of Manager Id item as:
${oa.EmployeePVO1.xxManagerRender}
5. In the processRequest() of the controller, add the following line of code:
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModu
le(webBean);
am.invokeMethod("createEmployee", null);

// This is what is added for PPR
am.invokeMethod("initPVO");
}
6. Supporting AM Code - Standard code to be cut-copied-pasted for PVO initializa
tion:
public void initPVO()
{
EmployeePVOImpl pvo = getEmployeePVO1();
// standard code to initialise PVO
if(pvo != null)
{
if(pvo.getFetchedRowCount() == 0)
{
// Oracle suggested workaround to query for VOs with only transient att
ributes with no select clause.
pvo.setMaxFetchSize(0);
pvo.executeQuery();
Row row = pvo.createRow();
pvo.insertRow(row);

EmployeePVORowImpl pvoRow = (EmployeePVORowImpl)pvo.getCurrentRow();
pvoRow.setRowKey(new Number(1));
}
}
// Change the method name to the name of actual PPR handling method in the
AM.
renderManagerItemOff();
}
7. In the pfr() of the controller, catch the PPR event and call AM:
if(event != null && event.equals("hideManagerItem"))
{
am.invokeMethod("renderManagerItemOff", null);
}
8. AM Code:
import oracle.jbo.domain.Number;
public void renderManagerItemOff()
{
// Read the value of POSITION_CODE from Employee Create VO's current Row
// If the Value = PRESIDENT, set xxManagerRender attribute of PVO = FALSE
EmployeeCreateVOImpl empVO = getEmployeeCreateVO1();
EmployeeCreateVORowImpl row = (EmployeeCreateVORowImpl)empVO.getCurrentRow(
);
String positionCode = row.getPositionCode();
EmployeePVOImpl pvo = getEmployeePVO1();
EmployeePVORowImpl pvoRow = (EmployeePVORowImpl)pvo.getCurrentRow();
if(positionCode == null || positionCode.equals("PRESIDENT"))
{
pvoRow.setxxManagerRender(Boolean.FALSE);
}
else
{
pvoRow.setxxManagerRender(Boolean.TRUE);
}
}
********************************************************************************
*
TABS
-----
TAB 1 | TAB 2 | TAB 3
----------------------
PAGE 1 PAGE 2 PAGE 3
Each page under tabs - can behave as an independent page with its own CO, AM, VO
etc.
PERSON | ASSIGNMENT | DUMMY
Recap of Tabs
----------------------
1. Created a new project
- New PersonVO, added to PersonAM
- New AssignmentVO, added to AssignmentAM
- A new AM - EmployeeInfoAM for the pageLayoutRN
2. Right Click on the Project, a new Page
- PageLayoutRN, AM Definition, Window and Page Title
3. Right Click on the PageLayoutRN, add a new region of style - subTabLayout
- Right Click on this subtabLayout, and add ANY NUMBER of regions of var
ious styles, each may have its own AM, CO, VO
- Effectively, each region under a tab can behave as an independent page
.
- Supposedly, you have created 4 regions under 4 tabs.
- Now, there needs to be 1-1 mapping between the LINKS pointing to regio
ns and the number of REGIONS created.
- We hence need to create 4 links. To create Links, right click on the r
egion of style 'subTabLayout' and select - SUBTABS.
- To the SubTab Region created, right click and add new LINKS.
- To the Links, provide TEXT property, which is the label for th
e link.
OAPageLayout Bean
|
-------- OASubTabLayout Bean
|
----- Header 1
|
--- Any Other Region / Item under it
|
------ Header 2
|
--- Any Other Region / Item under it
|
------ Header 3
|
--- Any Other Region / Item under it
|
------ Header 4
|
--- Any Other Region / Item under it
- InitialSubTab = 0 for SubtabLayoutRegion; this signifies that the firs
t tab would be displayed on the page, when the page renders. To change the defau
lt tab opening first, change the number accordingly.
********************************************************************************
*

Das könnte Ihnen auch gefallen