Thursday, December 26, 2013

How to make case Insensitive with top line filter values

This blog explains about case insensitive with <af:table> top line filter.

Scenario : Should ignore the Upper/Lower case with <af:table> top line filter values.

Resolution : set 'filterFeatures' property value to 'caseInsensitive'


Tuesday, December 24, 2013

How to get Selected Value of SelectOneChoice rather than in Index value in ADF


By default always <af:selectOneChoice> - ValueChangeListener() method gives the index rather than selected value.

Scenario : Get the selected short code of <af:selectOneChoice> component rather than getting index value in valueChangeListener() method binds to <af:selectOneChoice> component

Resolution
- Define ValueChangeListener for the <af:selectOneChoice> component as shown below


Perform below logic





How to invoke Backing Bean method and display popup simultaneously in ADF ?


This blog explains about invoking a backing bean method before displaying <af:popup>


Step1 - Define <af:popup> as shown below, Bind the popup to backing bean , I strongly recommend rather than binding to backing bean, Find the UI Component


Step2 - Bind to backing bean method as shown below


Step3 : Invoke the functionality whatever needed, then get the instance of the popup and invoke show() method as shown below.

How to display data bottom of each column in component using ADF


Scenario : To display sum of data in a specific column at the bottom table component , For eg : Display sum of salaries of all the employees in <af:table> component, corresponding to 'Salary' column in <af:table> component

Resolution :

Include <f:facet name="footer">Determine Sum of salaries </f:facet> in <af:column> component.

How to Hide Popup Progrmatically In ADF

This blog explains about how to hide a <af:popup> programatically ?

Resolution : Bind Popup Component to Managed Bean, Whenever you want to close the popup based on some condition ,  Get the instance of popup binding and invoke hide() operation.


    public void closeCreatePopup() {
        createPopupBinding.hide(); // createPopupBinding is popup binding
    }

java.sql.SQLSyntaxErrorException: ORA-01722: invalid number

This blog explains the root cause for ORA-01722 and steps need to be taken to resolve this issue.

Reason :  If you are trying to set a bind parameter value i.e String and comparing against  Numeric value you will see this error . For eg : You have empID = :BindEmpID , If you pass the :BindEmpID value as 'XYZ' then it will throw 'Invalid Number' exception because empID in database table is number field.

How to Resolve - Ensure always pass numeric values to bind paramenter when the corresponding bind parameter compares against numeric value

'Flex' Property in ADF , How to distribute uniform space between buttons in ADF


If you want to equally distribute the space b/w buttons , set 'flex' property as shown below, This will set uniform space b/w each button on toolbar container. Also adjust the width of the toolbar, So that it will display all the buttons always.

  <af:toolbar id="t2" flex="1">

java.util.MissingResourceException:Can't find bundle for base name


If you notice below exception when you deploy ADF application to any stand alone weblogic server, follow below steps to resolve.

Caused By: java.util.MissingResourceException: Can't find bundle for base name yourresourcebundlelocation, locale en_US
     at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1427)
     at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1250)
     at java.util.ResourceBundle.getBundle(ResourceBundle.java:705)
     at Searchusr.SearchModuleImpl.<clinit>(SearchModuleImpl.java:53)
     at java.lang.Class.forName0(Native Method)
     Truncated. see log file for complete stacktrace
>

Step1 : Ensure you specify complete path of your resource bundle name in all the pages.
Step2 : Specify the complete path in faces-config.xml as shown below

Step3 : Ensure specify complete path in UI Project Properties as shown below.

Tuesday, December 3, 2013

Most commonly used SQL commands

ALTER TABLE EMPLOYEES ADD AUDIT_ID NUMBER NOT NULL

ALTER TABLE EMPLOYEES DROP COLUMN AUDIT_ID NUMBER NOT NULL


- This query converts the 'String' Date Time object to date object and stores into database, Explains about using to_date() function.

INSERT INTO AUDIT(AUDIT_ID,ENTITY_NAME,AUDIT_KEY,ENTITY_ID,OPERATION,CREATED_BY,CREATION_DATE,LAST_UPDATED_BY,LAST_UPDATE_LOGIN,LAST_UPDATE_DATE) VALUES(23,'HEADERS','AGREEMENT_HEADER_ID','283','INSERT','admin',to_date('20090202121212','yyyyMMddHH24MISS'),'admin','admin',to_date('20090202121212','yyyyMMddHH24MISS'))

// Create DB Sequence

CREATE SEQUENCE  "HR"."EMPLOYEE_ID_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 61 CACHE 20 NOORDER  NOCYCLE ;

// Test DB Sequence using SQL Worksheet
select EMPLOYEE_ID_SEQ.nextval from dual

// Get first n Rows from the Database

SELECT * FROM EMPLOYEES WHERE ROWNUM <=5

// Alter the database table column
ALTER TABLE EMPLOYEE MODIFY SALARY NUMBER;

// Left Outer Join

The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the right table (table2). The result is NULL in the right side when there is no match.

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;

Monday, December 2, 2013

SQL Functions to perform IN() clause using ADF Business Components


This blog explains about performing IN() clause with comma separated values in ADF Business components.

Scenario 1 : Get all the employees where employee first name in ('Bob','Rob','Peter','Dan'), Using ADF Business components, pass the comma separated values as a bind parameter and execute the query using the SQL function which I am going to outline in below.

Scenario2 : Same as above, instead of String, 'Number' data type

FM_GN_IN_NUMBER_LIST  - This function accepts comma separated Numbers, delimit the String by ',' and returns array of numbers. So that we can avoid writing query to de


Function 1

// Create num_table type
CREATE TYPE num_table AS TABLE OF NUMBER;

create or replace
FUNCTION     FM_GN_IN_NUMBER_LIST (p_in_list  IN  VARCHAR2)
RETURN num_table
AS
l_tab   num_table := num_table();
l_text  VARCHAR2(32767) := p_in_list || ',';
l_idx   NUMBER;
BEGIN
LOOP
l_idx := INSTR(l_text, ',');
EXIT WHEN NVL(l_idx, 0) = 0;
l_tab.extend;
l_tab(l_tab.last) := to_number(TRIM(SUBSTR(l_text, 1, l_idx - 1)));
l_text := SUBSTR(l_text, l_idx + 1);
END LOOP;

RETURN l_tab;
END;

Function2:

//Create table_of_varchar type as shown below

CREATE TYPE table_of_varchar AS TABLE OF VARCHAR2(2300);

create or replace
FUNCTION     FM_GN_IN_STRING_LIST (p_in_list  IN  VARCHAR2)
RETURN table_of_varchar
AS
l_tab   table_of_varchar := table_of_varchar();
l_text  VARCHAR2(32767) := p_in_list || ',';
l_idx   NUMBER;
BEGIN
LOOP
l_idx := INSTR(l_text, ',');
EXIT WHEN NVL(l_idx, 0) = 0;
l_tab.extend;
l_tab(l_tab.last) := TRIM(SUBSTR(l_text, 1, l_idx - 1));
l_text := SUBSTR(l_text, l_idx + 1);
END LOOP;
RETURN l_tab;
END;

Usage: Below is the example, how to call the function

EmployeeEO.EMP_ID IN (SELECT * FROM TABLE(CAST(fm.fm_gn_in_string_list(:BineEmpID) AS fm.table_of_varchar)))