Posts

OAF :Formatting DateTime Fields

Use the following code to format DateTime feilds in OAF

OAWebBean departureDateBean = webBean.findChildRecursive("DepartureDate");

OANLSServices nls = pageContext.getOANLSServices();
oracle.cabo.ui.validate.Formatter formatter =
    new OADateValidater(nls.getUserJavaDateFormat() + " HH:mm",
                        nls.getUserRRRRJavaDateFormat() + " HH:mm");

departureDateBean.setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, formatter);

Thanks

OAF : Bundled Exceptions

Bundled exceptions let you accumulate "peer" exceptions while proceeding with validation, and then display them as a set when you are done. These peer exceptions are grouped in a container exception called a bundled exception.

To creat a bundled exception, you first must create a list to which you add exceptions as you encounter them:

ArryList peerExceptions = new ArrayList();
peerExceptions.add(new OAException(....));
peerExceptions.add(new OAException(....));

//Raise Exceptions
OAException.raiseBundledOAException(peerExceptions );

Thanks

OAF : Programmatically Add a Parameterized Pop-up

To programmatically add a parameterized pop-up to a component , add the following code in processRequest method

Step 1: Create an OAPopupBean   OAPopupBean popupBean1=(OAPopupBean)createWebBean(pageContext,POPUP_BEAN,null,"myPopup1");
popupBean1.setID("myPopup1");
popupBean1.setUINodeName("myPopup1");
popupBean1.setRegion("/oracle/apps/per/xyz/webui/PopupRN");
popupBean1.setHeight("130");
popupBean1.setWidth("320");
popupBean1.setTitle("Popup Title");
popupBean1.setParameters("personId={@PersonId}");
popupBean1.setType(PARAMETERIZED_POPUP);

Step 1: Add popup to item which you want to enable the pop-up, for example "EmpDtlBtn" buttonOAButtonBean empDtlBtnBean = (OAButtonBean)webBean.findChildRecursive("EmpDtlBtn");
empDtlBtnBean.setPopupEnabled(true);
empDtlBtnBean.setPopupRenderEvent("onClick");
empDtlBtnBean.setPopupID("myPopup1");
webBean.addIndexedChild(popupBean1);


Thanks

Casting Data Type in Oracle Database

CAST function 
The CAST function converts a value from one data type to another data type.

Syntax
CAST ( [ Expression | NULL | ? ] AS Datatype)

Note : CAST conversions among SQL-92 data types.
The flowing are SQL-92 data types
BOOLEANSMALLINTINTEGERBIGINTDECIMALREALDOUBLEFLOATCHARVARCHARLONG VARCHARCHAR VARCHARLONG VARCHARCLOBBLOBDATETIMETIMESTAMPXMLExamples
SELECT CAST (SYSDATE AS VARCHAR2 (12)) DATE_TO_VARCHAR FROM DUAL;
SELECT CAST ('12' AS INTEGER)  STRING_TO_NUMBERIC FROM DUAL;
SELECTCAST (NULL AS VARCHAR2 (2)) NULL_TO_STRING FROM DUAL;

As CAST only convert among SQL-92 data types, we can not use for example RAW data type.
But there are some packages casts to RAW like utl_raw.cast_to_raw

SELECT UTL_RAW.CAST_TO_RAW('Mahmoud') FROM DUAL;
output is : "4D61686D6F7564"

ADF : Send Parameter to actionListener method inside Bean

Image
actionListener method method can be invoked by Adf Button , Link and Image.
actionListeners methods have only one parameter of type javax.faces.event.ActionEvent.

if requirement is to send some parameter to that bean method who’s signature is something like
public void myActionListener(ActionEvent actionEvent)

The solution to achieve this requirement is putting an attribute tag from the JSF.Core inside the commandButton (or whatever actionable component you are using). So the code in the jsp page looks like this:



Now i can get the value in the bean method by using below code

public void myActionListener(ActionEvent actionEvent) {
  // Add event code here...
  String paramValue = (String)actionEvent.getComponent().getAttributes().get("paramName");
  System.out.println("paramValue = " + paramValue);
}


OAF : Number Format

In OAF, There is not format expression in BC4J like ADF, So you do formatting using controller classes.

There are 2 ways to format numbers in OAF

1- Format Numbers
Write this code  in processRequest method

import oracle.cabo.ui.validate.Formatter;

        Formatter formatter =
            new OADecimalValidater("###,###,##0.00", "###,###,##0.00");
        OAWebBean numericBean = webBean.findChildRecursive("<>");
        if (numericBean != null)
            numericBean.setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, formatter);

2- Format Number using currency format

Write this code  in processRequest method
        OAWebBean currencyBean = webBean.findChildRecursive("<>");
        if (currencyBean != null)
            currencyBean .setAttributeValue(CURRENCY_CODE, "USD");

Thanks

Display Calender in SQL and PLSQL

Image
Today I will present how to display calendar specific month from oracle SQL or PLSQL like below image


So I will present the solution to do this

First I will create Object type to handle week days( Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday)
CREATE OR REPLACE TYPE WEEK_DAY AS OBJECT (SUN NUMBER (2), MON NUMBER (2), TUE NUMBER (2), WED NUMBER (2), THU NUMBER (2), FRI NUMBER (2), SAT NUMBER (2));