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

What are the skills related to LOV in OAF development

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

The editor today takes you to understand what are the skills related to LOV in OAF development. The knowledge points in the article are introduced in great detail. Friends who feel helpful can follow the editor to browse the content of the article, hoping to help more friends who want to solve this problem to find the answer to the problem. Let's follow the editor to learn more about "what are the LOV-related skills in OAF development?"

In OAF development, LOV is used frequently. It consists of two parts: one is the LOV input box on the page (such as OAMessageLovInputBean), and the other is the pop-up LOV mode window (OAListOfValueBean). The button that the user selects LOV will pop up the LOV window, and the user will query and select the value in the LOV window, and can return to the LOV input box on the page. I won't dwell on how to create LOV here, just some of the apps you usually encounter:

1. Control the query results of LOV

2.LOV related events

3. Dynamic LOV

4.LOV Choice

First, control the query results of LOV

1, use Criteria

In many cases, a certain Item or several Item will be used to control the result of LOV. For example, there is a LOV of Item and an Organization on the page. Because Item is organized by inventory, there is such a demand. When I choose an inventory organization, the LOV of Item only shows the Item under that inventory organization.

To achieve this, you first need to put Organization in the LOV query statement as the result set (add the Oraganization_Id column to LOV's VO), then create a new Mapping,Mapping in Item and select OrganizationId in LOV Region Item (in LOV), while Criteria selects OrganizationId on the page. Note that these two are not the same Organization. One is in LOV and the other is on the page.

When Criteria sets the corresponding Item, when the LOV window pops up, it will be brought into the LOV window as a validation field, and the LOV view object will automatically bind this value as a query condition. Because this automatic binding is another conditional query on the result set of the query, you need to use Organization_Id as the query result set.

2,Passive Criteria

The Criteria Item of LOV can also be bound manually, that is, the field on the main page as Criteria Item is not automatically bound to the query of LOV after it is passed into LOV Region, but is dynamically bound by the developer. I think this method is designed for some advanced queries, such as adding exists to the query conditions according to a Flag field passed in. Such query conditions.

Using Passive Criteria, like LOV's normal Criteria Mapping, select LOV Region Item and Criteria Item, and then select Programmatic Query as True, so that LOV does not dynamically bind query conditions. After that, we create a CO on the Region of LOV and get the validation field in proce***equest:

Public void proce***equest (OAPageContext pageContext, OAWebBean webBean)

{

Super .proce * * equest (pageContext, webBean)

OAApplicationModule am = pageContext.getApplicationModule (webBean)

Dictionary passiveCriteria = pageContext.getLovCriteriaItems ()

/ / the LookupType here refers to the ID of the Lov Region Item in Mapping

String lovCriteria = (String) passiveCriteria.get ("LookupType")

OAViewObject lovVO = (OAViewObject) am.findViewObject ("FndLookupTypeLovVO1")

/ / limit the query results according to the obtained validation field

LovVO.setWhereClause ("")

LovVO.executeQuery ()

}

II. LOV event

For MessageTextInput,CheckBox, etc., you can use Client Action to trigger events, if a CheckBox, you can make a fireAction for it to control, such as changing the value of a field after a check box or some similar control. These events can be obtained using pageContext.getParameter (EVENT_PARAM) in the processFormRequest in the page CO. But there is no fireAction event in MessageLovInput. In fact, there are already some events in the Lov operation, which do not need to be defined by us. We can get the LOV event directly through pageContext.getParameter (EVENT_PARAM).

There are three types of LOV events, lovPrepare, lovUpdate, and lovValidate (returned by pageContext.getParameter (EVENT_PARAM)), all of which are triggered in the processFormRequest of the page CO. The event lovPrepare is triggered when the flashlight on the Lov is clicked. If a Lov is selected and returned to this page, the event lovUpdate will be triggered in the formRequest. When you enter a unique value in the Lov input box, Lov validation will be triggered. It should be noted that if you enter a non-unique value in the input box, the verification will automatically open the Lov window for you to choose, and the lovValidate event will not be triggered in formRequest at this time. When you select the value selected by LOV for the corresponding page processing (such as controlling whether other fields are displayed, etc.), you can judge the Lov event in processFormRequest and deal with it accordingly.

/ * * Item version control. When an Item with version control is selected, the Item version field can be modified. If there is no version control, the Item version field defaults to * * /

Super .processFormRequest (pageContext, webBean)

OAApplicationModule am = pageContext.getApplicationModule (webBean)

If ("ItemCode" .equals (pageContext.getLovInputSourceId ()

{

/ * * lovUpdate is triggered after Lov Region selects Item,lovValidate as input in the Lov MessageInput control, and determines whether Item has version control in this event * * /

If ("lovUpdate" .equals (pageContext.getParameter (EVENT_PARAM)

| | "lovValidate" .equals (pageContext.getParameter (EVENT_PARAM) |

{

/ * * Control the Revision field * * /

Am.invokeMethod ("controlRevSwitcher", new Serializable []

{pageContext.getParameter (SOURCE_PARAM)

PageContext.getParameter ("OrganizationIdFV")})

/ * * the controlRevSwitcher method controls the ReadOnly of the version control, but it cannot react immediately on the page. You need to use local refresh * * /

OAAdvancedTableBean tableBean =

(OAAdvancedTableBean) webBean.findChildRecursive ("VenTrxLinesAdvTbl")

TableBean.queryData (pageContext)

}

}

In the example above, because the LOV field is based on VO, the value of the selected LOV can be obtained in VO. However, for non-VO-based LOV, if you need to get the selected LOV value when the page event occurs, you need to obtain it in the following ways:

/ / Form was submitted because the user selected

/ / a value from the LOV modal window

/ / or because the user tabbed out of the LOV input.

/ / Find out which LOV input triggered the event.

String lovInputSourceId = pageContext.getParameter (SOURCE_PARAM)

/ / Find out the result values of the LOV.

Hashtable lovResults =

PageContext.getLovResultsFromSession (lovInputSourceId)

If (lovResults! = null)

{

System.out.println ("lovResults" + lovResults)

/ / Update the page depending on the value chosen by the user.

}

Third, dynamic LOV

The application of dynamic LOV is generally rare. In a previous document written by Shen Hui, it is achieved by creating a LOV and then dynamically changing the SQL of the LOV when a page event occurs. My method is implemented by directly dynamically creating a VO to associate with the Item in the LOV Region.

LOV is implemented by calling the Region we created on the page, so this LOV Region is the most important part of LOV, so in fact, when LOV VO does not exist, as long as there is Region, our LOV can be created. So we can first create a shell Region, then dynamically create the LOV VO when the main page opens, and finally associate the VO with the Table in the Region.

First, you need to create a LOV Region that is not associated with any VO. In my example, I created five MessageStyledText,5 FormValue. These fields simply set the Prompt property at this time, and the other properties are the default, including Data Type.

Next, create a LOV Bean in the Proce***equest of the main page (of course, you can also create a LOV in other page actions). And create a LOV VO.

Import java.io.Serializable

Import java.util.ArrayList

Import java.util.Hashtable

Import oracle.apps.fnd.common.VersionInfo

Import oracle.apps.fnd.framework.OAApplicationModule

Import oracle.apps.fnd.framework.webui.OAControllerImpl

Import oracle.apps.fnd.framework.webui.OAPageContext

Import oracle.apps.fnd.framework.webui.beans.OAWebBean

Import oracle.apps.fnd.framework.webui.beans.layout.OAHeaderBean

Import oracle.apps.fnd.framework.webui.beans.message.OAMessageLovInputBean

Public void proce***equest (OAPageContext pageContext, OAWebBean webBean)

{

Super .proce * * equest (pageContext, webBean)

OAApplicationModule am = pageContext.getApplicationModule (webBean)

/ *-create a LOV Bean---*/

OAHeaderBean headerBean = (OAHeaderBean) webBean.findChildRecursive ("TestHdRN")

OAMessageLovInputBean lovInput = (OAMessageLovInputBean) createWebBean (pageContext, LOV_TEXT, null, "InputTest")

HeaderBean.addIndexedChild (lovInput)

/ / Specify the path to the base page.

LovInput.setAttributeValue (REGION_CODE, "/ alther/oracle/apps/cux/checkboxtest/webui/CheckBoxTestPG")

/ / Specify the application id of the base page.

LovInput.setAttributeValue (REGION_APPLICATION_ID, new Integer (30001))

/ / the Region here is the Region you just created

LovInput.setLovRegion ("/ alther/oracle/apps/cux/lov/webui/CommonLovRN",)

LovInput.setUnvalidated (false)

LovInput.setPrompt ("Dynamic Lov")

/ / add Mapping relationship. Since LOV's Mapping is used in the initialization of the main page, you must create some empty Item to do Mapping, otherwise an error will be reported.

LovInput.addLovRelations (pageContext, "InputTest", / / base page item

"DisplayItem1", / / lov item

LOV_RESULT, / / direction

LOV_REQUIRED_NO)

LovInput.addLovRelations (pageContext, "InputTest", / / base page item

"DisplayItem1", / / lov item

LOV_CRITERIA, / / direction

LOV_REQUIRED_NO)

LovInput.addLovRelations (pageContext, "TestItem", / / base page item

"DisplayItem2", / / lov item

LOV_PASSIVE_CRITERIA, / / direction

LOV_REQUIRED_NO)

/ *-create a LOV VO---*/

ArrayList paramList = new ArrayList ()

String voName = "FndUserLovVO2"

String sql = "SELECT fu.user_id," +

"fu.user_name," +

"fu.start_date" +

"FROM fnd_user fu"

/ / paramList is the Attribute of each Item that is used to create a LOV and is used in association.

ParamList.add (new String [] {"UserId", "USER_ID", "oracle.jbo.domain.Number", null, "Hide", null})

ParamList.add (new String [] {"UserName", "USER_NAME", "java.lang.String", "100th", "Display", "SearchAllow"})

ParamList.add (new String [] {"StartDate", "START_DATE", "oracle.jbo.domain.Date", null, "Display", null})

/ / call the AM method to create a VO

Am.invokeMethod ("createVO", new Serializable [] {voName, sql, paramList}

New Class [] {String. Class, String. Class, paramList.getClass ()})

Am.getOADBTransaction () .putTransientValue (LovVOInstance, voName)

Am.getOADBTransaction () .putTransientValue (LovAttribute, paramList)

}

This is the way to create a VO in AM:

Import java.sql.Types

Import java.util.ArrayList

Import oracle.apps.fnd.framework.server.OAApplicationModuleImpl

Import oracle.apps.fnd.framework.server.OADBTransaction

Import oracle.apps.fnd.framework.server.OAViewDef

Import oracle.jbo.AttributeDef

Public void createVO (String voName, String sql, ArrayList list) {

OADBTransaction dbtx = getOADBTransaction ()

String [] attribute = new String [6]

Int types =-9999

OAViewDef viewDef = dbtx.createViewDef ()

ViewDef.setSql (sql)

ViewDef.setExpertMode (true)

ViewDef.setViewObjectClass ("oracle.apps.fnd.framework.server.OAViewObjectImpl")

ViewDef.setViewRowClass ("oracle.apps.fnd.framework.server.OAViewRowImpl")

For (int I =; I < list.size (); iTunes +) {

Attribute = (String []) list.get (I)

If ("java.lang.String" .equals (attribute [2])) {

Types = Types.VARCHAR

}

Else if ("oracle.jbo.domain.Number" .equals (attribute [2])) {

Types = Types.NUMERIC

}

Else if ("oracle.jbo.domain.Date" .equals (attribute [2])) {

Types = Types.DATE

}

If ("java.lang.String" .equals (attribute [2])) {

ViewDef.addSqlDerivedAttrDef (attribute [])

Attribute [1]

Attribute [2]

Types

False

True

AttributeDef.UPDATEABLE

Integer.parseInt (attribute [3]))

}

Else {

ViewDef.addSqlDerivedAttrDef (attribute [])

Attribute [1]

Attribute [2]

Types

False

True

AttributeDef.UPDATEABLE);}

}

If (findViewObject (voName)! = null) {

FindViewObject (voName) .remove ()

}

CreateViewObject (voName, viewDef)

}

Finally, in the CO of LOV Region, add the associated code. It is important to note that since our LOV VO is created under the AM of the main page, the AM of the LOV Region must be the same as the AM of the main page. Otherwise, variables on the main page cannot be passed to LOV Region.

Public void proce***equest (OAPageContext pageContext, OAWebBean webBean)

{

Super .proce * * equest (pageContext, webBean)

OAApplicationModule am = pageContext.getApplicationModule (webBean)

String voInstance = (String) am.getOADBTransaction () .getTransientValue ("LovVOInstance")

ArrayList paramList = (ArrayList) am.getOADBTransaction () .getTransientValue ("LovAttribute")

String [] attribute = new String [6]

Int dispalyIndex = 1

Int hideIndex = 1

/ / Associate VO

((OAListOfValuesBean) webBean) .setViewUsageName (voInstance)

/ / set all MessageStyledText in Region to not display

For (int I = 1; I

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

Database

Wechat

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

12
Report