24 October, 2018
In this lesson, we are going to learn how to display Oracle Applications User Name, User Id, Responsibility Name and Responsibility Id.
We will see little bit java programming too in this chapter.
Steps to follow:
Here I am taking the page which is already created and adding a region with region style as ” message Component Layout “.
After adding Region under region here, we are creating four items and Item style of all the four items is “ message Text Input ”.
After adding Region and Items, the page structure will look like:
Now change the prompt values for each item as follows:
(if you want to know how to change the prompt values in the Property Inspector see the Previous Chapter which shows how to change the prompt value)
item1 -> User ID
item2 -> User Name
item3 -> Responsibility ID
item4 -> Responsibility Name
The below picture shows how the output structure looks like after running the page, just have a look into it
Now we need to create a Controller, let us see how to create a controller in JDeveloper (OAF).
Best practice is to create the controller Globally so that it should be applicable to all the child regions.
Right Click on the Main Region and then select Set New Controller…
After choosing Set New Controller, one dialog box window opens, and it shows some default package and also some default name, in Package name at last we will find ”.webui.webui” change it to single webui i.e, nothing but remove one WebUI from the default package name, for example, assume the default package is as follows:
change it to
If you want to know why webui is there at the end means you can see the BC4J file Structure lesson which displays the file structures.
give the class name, and we know that every controller ends with CO. For example, give the controller name as WelcomeCO as shown below:
Click on OK button after giving Class Name and also after deleting one WebUI from the package. Now if you observe Applications Navigator structure controller is created under webui. Select the controller (WelcomeCO.java) and see the java program how it looks.
In the java program, WelcomeCO class is created which is extending OAControllerImpl which contains the main method.
We can also see two methods namely
1) public void processRequest(OAPageContext pageContext, OAWebBean webBean)
The above method is used whenever we want any logic to be implemented before the page gets loaded. It means while loading a page if we want to display (or) perform any business logic then we go for processRequest.
2) public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
This method is used if we want any changes to be made once after the page gets loaded, i.e, After the page is loaded suppose after clicking on a particular button if we want to display the result into another item or after clicking on the button if we want to go to another page.
As of now, our requirement is to display the User ID, User Name, Responsibility ID, Responsibility Name whenever page gets loaded all the fields automatically to be displayed in the respective items. So, therefore, we need to write our program logic in the processRequest.
Look at the below figure we declared four variables of type String, and if you observe for number/id values, we are just converting those values into the string. In the OAPageContext, we will be having some defined values which we can access as shown in the below figure using notation dot (.) we will get all the available values and then we need to choose the required one.
“pageContext” is nothing but the variable name of the OAPageContext (OracleApps page Context), if you observe to declared four variables we assigned values respectively.
Now after declaring variables and assigning values to the variables, we need to search for items on our page, if you observe we created four items item1, item2, item3, and item4. So, therefore, to find the items on the page we need to use the bean as follows:
Here in this lesson, we are not providing access to copy and paste the code of java because whenever we are typing code JDeveloper prompts us to import the packages automatically. For example look at the below figure whenever we start typing, JDeveloper prompts us to click on Alt-Enter so that we can import the required package. It just saves our typing time of importing a package.
After clicking on Alt-Enter, it displays the packages list then choose the required import package. Here we are typing OAMessageTextInput it is a bean if you observe we used item style as “MessagetextInput” we are just adding OA (OracleApps) at the beginning and Bean at last which gives our Bean name. Now look at the below figure which shows the imported package name:
If you observe first, we initialized a bean, and at the time of initialization, we also need to import the respective package and hence now we know that how to import the required package automatically. After that declare a variable and we used Java typecasting process here.
Every item has its id, so we used id value of the item to find the required item in the page.
Similarly, write the code to find all the items on the page which we created.
Now after finding the items on the page we need to assign values which we got using pageContext into the respective items. It means we need to set a value for each item in the page and for that, we use the line code as follows:
Similarly set values to all the items and after that, the code looks like:
Rebuild the program after finishing the code, just Right click on the code area and then select Rebuild option or we can also use a short cut code Alt+Shift+f9. The same scenario is shown in the below figure:
After successfully rebuilding the java program Run the page and see the output. The output of the page which we created is as follows:
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .