Retrieve GET parameters from URL in Managed Bean in Oracle ADF

For obtaining parameter from URL in java code in Oracle ADF use the below code
URL:
http://127.0.0.1:7101/Application-ViewController-context-root/faces/page.jspx?paramName=Testing123
Use the code:
String test = FacesContext.
getCurrentInstance().getExternalContext().getRequestParameterMap().get("paramName");

How to create new Portal in WebCenter Portal

In this tutorial, we will create a small portal application in the Oracle WebCenter Portal.

How to start up Oracle WebCenter Portal

In this small tutorial we just start up the Web Center Portal and Navigate around.

Prerequisite: Installation should be complete

Steps:

  1. Navigate to Oracle Middleware Home(in my case C:/Oracle/mw10.3.6)
  2. Navigate to the Application Domain(C:Oraclemw10.3.6user_projectsdomainsportal_domain)
  3. Execute startWeblogic.cmd(or .sh in case of linux)
  4. Once the Server comes to running state, navigate to bin folder in the same folder and execute the following command

    startManagedWeblogic.cmd WC_Spaces http://localhost:7001

  5. The script would ask you about the username and password of the weblogic user.
  6. Once in running state, open browser and enter the following URL:

    http://localhost:8888/webcenter

Result:

“MDS_INTERNAL_SHREDDED” has errors … while starting Oracle WebCenter Portal

I got below error while starting Oracle WebCenter Portal server with on Oracle XE 10g database.

MDS-01370: MetadataStore configuration for metadata-store-usage “OWSM_TargetRepos” is invalid.
ORA-04063: package body “DEV_MDS.MDS_INTERNAL_SHREDDED” has errors
ORA-06508: PL/SQL: could not find program unit being called: “DEV_MDS.MDS_INTERNAL_SHREDDED”

When this error happen WebCenter Portal Managed Server is not started.
Please follow below steps to resolve the issue.

  • Stop server
  • Drop the all related database schemas using RCU.
  • Connect to XE database using sqlplus command through command prompt.
  • Connect sys as SYSDBA and provide a password for SYS user

    alter system set sga_target=350M scope=spfile;
    alter system set sga_max_size=350M scope=spfile;
    shutdown immediate
    startup

  • set RCU_JDBC_TRIM_BLOCKS=TRUE environment variable and run RCU to create schemas again.
  • Verify if RCU_JDBC_TRIM_BLOCKS set properly.

    set RCU_JDBC_TRIM_BLOCKS=TRUE Echo % RCU_JDBC_TRIM_BLOCKS % — this has to return TRUE

    Now run rcu.bat in same command prompt window and create required schemas.
    Note : This issue will happen only on XE 10g database.

How to pass Service Name or SID in JDBC URL

Below is the way to send either Service Name or SID in JDBC URL to connect to Oracle SQL

For Service Name

@//host_name:port_number/service_name
For example:
jdbc:oracle:thin:scott/tiger@//myhost:1521/myservicename

For SID

@//host_name:port_number:service_name
For example:
jdbc:oracle:thin:scott/tiger@//myhost:1521:myservicename

Oracle DOC

How to add ValueChangeListener Programmatically

Using an EL String, we can add ValueChangeListener in Oracle ADF using the below code:

private static MethodBinding getValueChangeListener(String el) {
        Class[] parms = new Class[] { ValueChangeEvent.class };
        MethodBinding mb =
            FacesContext.getCurrentInstance().getApplication().createMethodBinding(el,
                                                                                   parms);
        return mb;
    }

pass the EL Expression to the util method

ui.setValueChangeListener(getValueChangeListener("#{pageFlowScope.demoBean.valueChangeListener}")); 

 

Fastest 3 out of 25 Horses Problem

Problem Statement

You have 25 horses, and you want to pick the fastest 3 horses out of those 25. Each race can have maximum of 5 horses at the same time. What is the minimum number of races required to find the 3 fastest horses without using a stopwatch?

Solution

Let’s say that we have 5 races of 5 horses each, so each row in the table above represents a race.

H1 H2 H3 H4 H5
H6 H7 H8 H9 H10
H11 H12 H13 H14 H15
H16 H17 H18 H19 H20
H21 H22 H23 H24 H25

Let each row represent a race.

Step 1: Perform 5 races of each set.

Result:

1st 2nd 3rd 4th 5th
H1 H2 H3 H4 H5
H6 H7 H8 H9 H10
H11 H12 H13 H14 H15
H16 H17 H18 H19 H20
H21 H22 H23 H24 H25

Step 2: Elimination by logical analysis:

  • We can eliminate the slowest 2 horses in each group since those horses are definitely not in the top 3
  • The 5 group leaders are not necessarily the 5 fastest horses, therefore race those 5 horses against each other (H1, H6, H11, H16, and H21) {Race 6}, Let’s say that the 3 fastest in that group are H1, H6, and H11 – automatically we can eliminate H16 and H21 since those 2 are definitely not in the top 3
  • We can automatically eliminate all the horses that H16 and H21 competed against in the preliminary races as they were slower than H16 and H21
  • We also know that H1 is the fastest horse in the group since he was the fastest horse out of the 5 group leaders
  • if H6 and H11 are the 2nd and 3rd fastest in the group leaders, then we should be able to eliminate H8 since H6 raced against him and he was in 3rd place in that race
  • We can also eliminate H12 and H13 since H11 was the 3rd fastest in the group leaders, and H12 and H13 were slower than H11
  • This leaves us with the following horses to determine the 2nd and 3rd fastest horses:
H2 H3 H6 H7 H11

Race the last Set {Race 7} to get the Top 2nd and 3rd racers with H1 as the fastest.

Total number of Races: 7

Enable/Disable Proxy Service in OSB via ANT+Python

Below is the configurable code for developers to maintain an ant script to be able to control(Enable/Disable) Proxy Services via Ant Script.

Files:


WLSTbuild.properties

weblogic.home.dir=<OSB Home>/wlserver_10.3
weblogic.lib.dir=${weblogic.home.dir}/server/lib


build.properties

fmw.home=<OSB Middleware Home>
wls.username =<Weblogic User Id>
wls.password =<Weblogic Password>
wls.server = t3://:<Weblogic Host>:<Weblogic Port>
service.script=osb_enable_service.py
service.project="<Project Name>/<Sub Project Name or 'ProxyServices' >"
service.name =<Proxy Name>
service.action = <disable/enable>


build.xml

<?xml version="1.0" encoding="windows-1252" ?>
<project name="ServiceControl" default="ServiceControl">
   <property file="./build.properties"/>
   <property file="./wlstbuild.properties"/>
   <taskdef classname="weblogic.ant.taskdefs.management.WLSTTask" name="wlst">
      <classpath>
         <pathelement location="${weblogic.lib.dir}/weblogic.jar"></pathelement>
      </classpath>
   </taskdef>
   <target name="ServiceControl">
      <echo>${weblogic.lib.dir}</echo>
      <wlst filename="${service.script}" debug="true" failonerror="false"
            arguments="${wls.username} ${wls.password} ${wls.server} ${service.project} ${service.name} ${service.action}">
         <classpath>
            <pathelement location="${weblogic.lib.dir}/weblogic.jar"></pathelement>
            <pathelement location="${fmw.home}/<OSB Installation Folder>/lib/sb-kernel-api.jar"></pathelement>
            <pathelement location="${fmw.home}/<OSB Installation Folder>/lib/sb-kernel-impl.jar"></pathelement>
            <pathelement location="${fmw.home}/<OSB Installation Folder>/lib/osb-coherence-client.jar"></pathelement>
         </classpath>
      </wlst>
   </target>
</project>

osb_enable_service.py

from com.bea.wli.sb.management.configuration import SessionManagementMBean
from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
from com.bea.wli.config import Ref
from java.lang import String
from com.bea.wli.monitoring import StatisticType
from com.bea.wli.config import Ref
from com.bea.wli.sb.util import Refs
from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean
from java.lang import String
from com.bea.wli.monitoring import StatisticType
from com.bea.wli.config import Ref
from com.bea.wli.sb.util import Refs
from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean
adminUser = sys.argv[1]
adminPassword = sys.argv[2]
adminUrl = sys.argv[3]
project = sys.argv[4]
service = sys.argv[5]
action = sys.argv[6]
connect(adminUser,adminPassword,adminUrl)
domainRuntime()
print('WLST Connected')

Create a session name

sessionName = String("SessionScript"+Long(System.currentTimeMillis()).toString())
print('... after session. Session is: ', sessionName)

Get the session MBean and create a session

sessionMBean = findService(SessionManagementMBean.NAME,SessionManagementMBean.TYPE)
print('SessionMBean is: ', sessionMBean)
sessionMBean.createSession(sessionName)
print(String('Session was created ... ').concat(sessionName))

Get the ProxyServiceConfigurationMBean specific to our session

mbean = findService(String("ProxyServiceConfiguration.").concat(sessionName),'com.bea.wli.sb.management.configuration.ProxyServiceConfigurationMBean')

Creates a reference to a folder and 'ProxyServices' is a folder in the project and 'ProxyServices' is a folder in the project

projectName = Refs.makeParentRef(project + '/')
proxyRef = Refs.makeProxyRef(projectName, service)
if action == 'disable' :
print "Disabling " + service +" has been completed"
mbean.disableService(proxyRef)
else :
print "Enabling " + service +" has been completed"
mbean.enableService(proxyRef)

Now commit (activate) the changes

sessionMBean.activateSession(sessionName, "disabled PS")
print
disconnect()
exit()

Place all files in a single folder.

From CMD, Navigate to folder and just call ant

Verify from OSB Portal, the service will be in disabled/enabled format in Operational Settings Tab.

How to install Web Center Portal

Installing Oracle Web Center Portal has the following steps:

  • Download and Install:
    1. Weblogic Server 10.3.6 <!! 12c would not work, Only 11g Release 2 !!>
    2. Web Center Portal
      F
      ollow the complete steps or follow the wizard as shown:
      install_welcome
      install_software_updates
      install_prereqs
      install_location
      install_app_server
      *Please Note: Weblogic option will not be available if the Server version mentioned in the previous step is not 10.3.6. 12c will not work
      install_summary
      install_progress
      install_complete
    3. Database XE(Optional. install only if you dont have database already installed)
    4. RCU
      • In CMD, Open file

        <Download_folder>ofm_rcu_win_11.1.1.8.0_64_disk1_1of1rcuHomeBIN

      • Follow the below steps to install RCU:
        2015-05-05_1724 2015-05-05_1725 2015-05-05_1726 2015-05-05_1726_001 2015-05-05_1727 2015-05-05_1729 2015-05-05_1729_001 2015-05-05_1729_002 2015-05-05_1729_003 2015-05-05_1730 2015-05-05_1730_001 2015-05-05_1731 2015-05-05_1731_001 2015-05-05_1809
  • Configure Domain Config:
    2015-05-05_1818

    2015-05-05_1818_001
    2015-05-05_1819
    2015-05-05_1819_001 2015-05-05_1819_002

    2015-05-05_1820
    2015-05-05_1821
    2015-05-05_1822
    2015-05-05_1822_001
    2015-05-05_1822_002 2015-05-05_1822_003