Posts

Showing posts from August, 2012

ADF : Get Key from Resource Bundle

Resource bundles contain locale-specific objects.
In this way, you can write program code that is largely independent of the user's locale isolating most, if not all, of the locale-specific information in resource bundles.

This allows you to write programs that can:
    a- be easily localized, or translated, into different languages
    b- handle multiple locales at once
    c- be easily modified later to support even more locales

DBMS_COMPARISON Package

DBMS_COMPARISON is a new package introduced by oracle in database 11g which is used for comparing database objects in different databases.

The DBMS_COMPARISON package can compare the following types of database objects:
    a- Tables
    b- Single-table views
    c- Materialized views
    d- Synonyms for tables, single-table views, and materialized views

The DBMS_COMPARISON package cannot compare data in columns of the following data types:
    a- LONG
    b- LONG RAW
    c- ROWID
    d- UROWID
    e- CLOB
    f- NCLOB
    g- BLOB
    h- BFILE
    i- User-defined types (including object types, REFs, varrays, and nested tables)
    j- Oracle-supplied types (including any types, XML types, spatial types, and media types)

Footer in Ireport

Image
I always print in report footer  some data about displaying date and pages counter like below image
I will explain how to execute this in Ireport

ADF Faces : Get Child Component

You can use the code snippet for finding child component under parent component  in ADF Faces.

public static FacesContext getFacesContext() { return FacesContext.getCurrentInstance(); } public static UIComponent getChildUIComponent(String ParentUI, String ChildUI) { UIComponent parentUI = getFacesContext().getViewRoot().findComponent(ParentUI); UIComponent childUI = null; UIComponent tempUI = null; Iterator childrens = parentUI.getFacetsAndChildren(); while (childrens.hasNext()) { tempUI = (UIComponent)childrens.next(); if (ChildUI.equals(tempUI.getId())) { childUI = tempUI; break; } } return childUI; }
Import the following Classes

import javax.faces.component.UIComponent; import javax.faces.context.FacesContext;
Thanks

CHAR vs VARCHAR vs VARCHAR2

Image
Today I will present short notes about popular string data types in SQL and PLSQL.

CHAR it is used for storing fix length character strings. String values will be space/blank padded before stored on disk. If this type is used to store variable length strings, it will waste a lot of disk space.
Example
CREATE TABLE CHAR_TAB (CHAR_COL CHAR (10));
INSERT INTO CHAR_TAB (CHAR_COL) VALUES ('Mahmoud'); COMMIT;
Let's now select data and lenght of data and dump of data in table CHAR_TAB
SELECT CHAR_COL, LENGTH (CHAR_COL), DUMP (CHAR_COL) FROM CHAR_TAB;
The output will be like
As We noticed in result that length is 10 characters inspire of I entered 'Mahmoud' which has only 7 characters.
We also noticed that in dump he padded at latest ASCII code three times number 32 which is ASCII code of space.

ADF : Filter View Object Rows

In this post I explain how to filter rows in ViewObject and RowSetIterator.
Primarily, filter the rows means return a set of rows from ViewObject or RowSetterator according specific criteria which is filtered in memory only.

1- Filter ViewObject
//Get ViewObjectImpl object ViewObjectImpl vo = getDeptVO(); //Filter using specific attribute value Row[] filteredRows = vo.getFilteredRows("AttributeName", "AttributeValue"); //Filter using RowQualifier Class //Use RowQualifier if you have more than one condition in filtering rows RowQualifier rowQualifier = new RowQualifier(vo); rowQualifier.setWhereClause("AttributeName=AttributeValue"); filteredRows = vo.getFilteredRows(rowQualifier);
2- Filter RowSetIterator
//Get ViewObjectImpl object ViewObjectImpl vo = getAllAdvisorView(); //Get RowSetIteratorImpl object RowSetIterator rsIterator=vo.createRowSetIterator(null)…

Generate Random Password in Oracle

In my application I need to generate password for users first time after registration.
The generated password must has some criteria which system administrator will configure it.
1- Character should be UPPERCASE                              =====> Abbreviation [U]
2- Character should be LOWERCASE               =====> Abbreviation [L]
3- Character should be NUMBER                  =====> Abbreviation [N]
4- Character should be any character                 =====> Abbreviation [A]
5- Character should be NON-ALPHANUMERIC character =====> Abbreviation [S]

So I thought to create dynamic function "RANDOM_PASSWORD" to return random password regarding to previous criteria.
The the system administrator will pass criteria per every character in password text to function and it will return random password
For example :-
first character should be UPPERCASE               ======> U
second character should be LOWERCASE          ======> L
third character should b…