Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

OAF Personalized Development example (to be transferred)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

EBS 11.5.10.2

Demand

The following figure is the Oracle standard page, there is a simple development requirement, when Expense Template is equal to "administrative expenses", the LOV input box of Approver defaults to "XXX", and LOV is read-only and cannot be selected.

Analysis.

This seems to be an extremely simple development, but the technical knowledge behind it is not so simple.

When Expense Template selects "administrative expenses", the Approver LOV input box is read-only, and the development involved here is basically to add the function of FireAction to Expense Template.

Then modify the read-only property of Approver LOV in the Value Change event of Expense Template.

Because the development specification does not allow direct modification of Oracle code, this development will integrate standard controller classes, implement the FireAction function of adding Expense Template in customized controller classes, and modify Approver LOV read-only properties.

Then, through personalization, the controller class is replaced with a customized controller class.

Technical key points

1. Modify the read-only attribute of Approver LOV

Developers who have just done OAF development may find it easy to call the following code in the processFormRequest () method of the custom controller class:

OAMessageLovInputBean lovBean = (OAMessageLovInputBean) webBean.findChildRecursive ("Approver"); lovBean.setReadOnly (true); can be implemented, and if you do this, it would be wrong to throw an exception at run time: The OA passivation framework coding standard has been violated. Web bean properties cannot be modified in the controller processFormData or processFormRequest method. Web bean properties should be modified in the processRequest method only.

(there are two exceptions, setValue () and setText (), because Value does not affect the control tree.) Why is it wrong to make LOV read-only? This is because OAF behaves as a control tree at run time.

When entering the page, the control tree is initialized and created, but when a user event triggers a POST request, the control tree is not regenerated (improving performance). There are only two ways to change the properties of the control, one is to regenerate the control tree, and the other is to use PPR.

Method 1: reconstruct the control tree

Refactoring the control tree means that when the processFormRequest () method handles events, you need to Forward to this page and set Approver LOV read-only through parameter control, which refreshes the entire page and makes coding difficult.

Method 2: use PPR

The implementation method is to use the OAF data binding mechanism to bind the ReadOnly property of Approver LOV to the property of the view object, and to control the read-only of Approver LOV by changing the value of the property of the view object.

Here comes the second technical point:

2. Create view objects dynamically

To create a view object, you need to first create an OAViewDef object, and then use the OAViewDef object to create a view object.

Here, let's talk about a development specification of Oracle. The OAViewDef interface is under the oracle.apps.fnd.framework.server package. According to the Oracle specification, any class under webui is not allowed to import any class under server. I am a strict follower of specifications, which makes development more complicated.

To reference the OAViewDef interface under the server package, you must create an application module and move the code that dynamically creates the view object into the application module for implementation. In the custom controller class, create the application module dynamically, and then call the method of the application module.

Implementation steps

Assume that the developer already knows a lot about the page structure of the Oracle standard, including which standard controller needs to be integrated and the view objects used on the page.

1. Create a custom application module cux.oracle.apps.ap.oie.entry.server.CuxPVOAM

2. Create the view object cux.oracle.apps.ap.oie.entry.server.CuxPVO. There is only one temporary property ReadOnlyFlag in the view object, and the type is Boolean (this step is optional)

3. Create a custom controller class and inherit the standard controller class

4. Create two methods in CuxPVOAMImpl.java:

Import oracle.apps.fnd.framework.OAViewObject;import oracle.apps.fnd.framework.server.OAViewDefImpl;import oracle.jbo.AttributeDef;import oracle.jbo.Row;... Public void initPVO () {OAApplicationModuleImpl rootAM = (OAApplicationModuleImpl) getRootApplicationModule (); / / create a view object OAViewDefImpl viewDef = (OAViewDefImpl viewDef) getOADBTransaction () .createViewDef (); viewDef.setFullName ("CuxPVODef"); viewDef.setViewObjectClass ("oracle.apps.fnd.framework.server.OAViewObjectImpl") ViewDef.addTransientAttrDef ("ReadOnlyFlag", "java.lang.Boolean", null, false, AttributeDef.UPDATEABLE); OAViewObject pvo = (OAViewObject) rootAM.createViewObject ("CuxViewPVO", viewDef) / / initialize PVO if (! pvo.isPreparedForExecution ()) {pvo.executeQuery ();} pvo.setMaxFetchSize (1); Row row = pvo.createRow (); pvo.insertRow (row); row.setAttribute ("ReadOnlyFlag", Boolean.FALSE);} public void handleTemplateChange () {OAApplicationModuleImpl rootAM = (OAApplicationModuleImpl) getRootApplicationModule (); OAViewObject vo = (OAViewObject) rootAM.findViewObject ("XxxVO1") / / Standard VO OAViewObject pvo = (OAViewObject) rootAM.findViewObject ("CuxViewPVO"); if () {pvo.first (). SetAttribute ("ReadOnlyFlag", Boolean.TRUE); vo.first (). SetAttribute ("Xxx",); / / set the property value of the view object bound by Approver LOV} else {pvo.first (). SetAttribute ("ReadOnlyFlag", Boolean.FALSE);}

5. Add the corresponding code to the customized controller

ProcessRequest Code:

Public void processRequest (OAPageContext pageContext, OAWebBean webBean) {super.processRequest (pageContext, webBean); / / enable the FireAction function of ExpenseTemplate OAMessageChoiceBean choiceBean = (OAMessageChoiceBean) webBean.findChildRecursive ("ExpenseTemplate"); choiceBean.setFireActionForSubmit ("change", null, null, true) / / create a custom application module OAApplicationModule rootAM = pageContext.getRootApplicationModule (); OAApplicationModule pvoAM = (OAApplicationModule) rootAM.findApplicationModule ("CuxPVOAM"); if (pvoAM = = null) {rootAM.createApplicationModule ("CuxPVOAM", "cux.oracle.apps.ap.oie.entry.server.CuxPVOAM"); pvoAM = HssCustomizeHelper.getNestedAMInstance (rootAM, "CuxPVOAM");} pvoAM.invokeMethod ("initPVO") / / bind the ReadOnly property to the view object property OAMessageLovBean approverLov = (OAMessageChoiceBean) webBean.findChildRecursive ("Approver"); approverLov.setAttributeValue (READ_ONLY_ATTR, new OADataBoundValueViewObject (approverLov, "ReadOnlyFlag", "CuxPVO");}

Publish the tested code to the server. (the test can be done locally, replacing the controller class on the page with a custom controller.)

ProcessFormRequest Code:

Public void processFormRequest (OAPageContext pageContext, OAWebBean webBean) {super.processFormRequest (pageContext, webBean); OAApplicationModule rootAM = pageContext.getRootApplicationModule (); OAApplicationModule pvoAM = (OAApplicationModule) rootAM.findApplicationModule ("CuxPVOAM"); if (pvoAM = = null) {rootAM.createApplicationModule ("CuxPVOAM", "cux.oracle.apps.ap.oie.entry.server.CuxPVOAM"); pvoAM = HssCustomizeHelper.getNestedAMInstance (rootAM, "CuxPVOAM") } if ("change" .equals (pageContext.getParameter (EVENT_PARAM) {pvoAM.invokeMethod ("handleTemplateChange");}}

The code for HssCustomizeHelper.getNestedAMInstance () is as follows:

Public static OAApplicationModule getNestedAMInstance (OAApplicationModule parentAM, String nestedAMName) {OAApplicationModule am = null; String [] amNames = parentAM.getApplicationModuleNames (); for (int item0; itemlt; amNames.length; iTunes +) {if (amNames.endsWith (nestedAMName)) {return (OAApplicationModule) parentAM.findApplicationModule (amNames [I]);} else {am = getNestedAMInstance ((OAApplicationModule) parentAM.findApplicationModule (amNames [I]), nestedAMName) If (am! = null) {return am;} return am;}

7. Restart Apache

8. Enter the page, set up personalization, and replace the standard controller class with the customized controller class.

-

1.jpg

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report