Thursday, August 29, 2013

How to Freeze multiple columns in ADF ?

This blog explains about how to freeze columns dynamically using <af:table> component.

- Set columnSelection="true" property



- When you set above property, You will notice 'Freeze' button automatically enabled on PanelCollection. User can select multiple columns and press 'Freeze' button.




Fortune Minds - Oracle ADF: How to set Width to af:selectOneChoice component ?...

Fortune Minds - Oracle ADF: How to set Width to af:selectOneChoice component ?...: How to set Width to <af:selectOneChoice> component ?

How to Configure Servlet with ADF Faces ?


This blog explains about configuring Servlet class with ADF Page Fragment or ADF Page.

Expected Result : Whenever JSFF/JSPX page opens invoke doGet() method in Servlet class, Get the Application Module class using Databindings and invoke the method.

Implementation

- Create a Servlet class in ViewController project, which should extend to HttpServlet and override doGet() method as shown below.
- This method obtains the Application Module Impl class using Data Controller Frame name and Data Controller name. This is one of the best practice to obtain AMImpl instance in non ADF classes.

- Configure newly created Servlet in Web.xml as shown below.


- Define <af:inlineFrame> component in Page or Pagefragment as shown below, Here source value should exactly match with the servlet mapping in web.xml. This will invoke respective servlet whenever page launches.

- Implement initialize method in backing bean correspond to Page fragment, this will store the 'Data Control Frame Name' into Session scope.

- Finally, When you launch page fragment, you will see the output in console as shown below.



Tuesday, August 27, 2013

How to handles exceptions in ADF Taskflow ?


This blog explains about handling unexpected exceptions in ADF Task flow, There might be several reasons to occur exceptions in Taskflow , for eg : Any activity associated to taskflow may contribute to any type of exception, We can handle all these kind of exceptions in a single method.



- Assume, This taskflow has one initializer method, which is default activity and this method generating 'NullPointerException'.
- Define another method activity as shown below 'ExceptionHandler' , bind this method to backing bean. Mark this method activity as 'Exception Handler' by clicking on '!' component in the toolbar.

- Below is the source code for 'initialize' method activity

- Below is source code for 'ExceptionHandler' method activity



- Here is backing bean code for 'ExceptionHandler' method activity, Here you can define what ever error/exception message you want to display.

- Below is source code for 'initialize' method activity, Resulting 'NullPointerException'

- Below is how warning message displayed while loading this page.



How to implement Security to ADF application using Custom DB Tables (SQL Authenticator)


This blog explains about configuring 'ReadOnlySQLAuthenticator' in Weblogic console and giving access to ADF applications.

Overview :

SQL Read only authenticator connects to configured database based on the data source and pull the users, groups from the respective database tables based on the queries we configure part of 'SQL ReadOnlyAuthenticator' Provider. This will allow only to read the data from database tables/ views, but no way user can update any information related to users/groups into database tables, whereas 'SQL Authenticator' can allow to modify Users/Groups related information to database tables.

Implementation :

- Login to Weblogic Console.
- Choose Security Realms -> myRealm->Providers->New ->
- Give the proper name to the Provider
- Choose Type as 'ReadOnlySQLAuthenticator'
- After creating new provider, Select the newly created provider in Authentication Providers list
- Choose 'Control Flag' as 'OPTIONAL' Below is the brief information about various possible values for 'Control Flag'



- Enter the below information in 'Provider Specific' , This is very important section and must be validated queries thoroughly. Must have three different database tables

- USERS - This table maintain about users related information such as user name, password, description etc
- GROUPS - This table maintain about groups related information such as group name, description etc.
- USER_GRP- This table maintain association between users and groups.

- Give valid data source name

SQL Get Users Password:  SELECT U_PASSWORD FROM USERS WHERE U_NAME = ?

SQL User Exists : SELECT U_NAME FROM USERS WHERE U_NAME = ?

SQL List Users : SELECT U_NAME FROM USERS WHERE U_NAME LIKE ?

SQL List Groups : SELECT G_NAME FROM GROUPS WHERE G_NAME LIKE ?

SQL Group Exists : SELECT G_NAME FROM GROUPS WHERE G_NAME = ?

SQL Is Member : SELECT u.U_NAME FROM USER_GRP g ,USERS u WHERE u.USER_ID = g.USER_ID and GROUP_ID = ( select G_ID from GROUPS where G_NAME = ? ) AND USER_ID = ( select USER_ID from USERS where U_NAME = ? )

SQL List Member Groups : SELECT G_NAME FROM USER_GRP g ,GROUPS r,USERS u WHERE g.USER_ID = u.USER_ID and g.GROUP_ID = r.G_ID and u.U_NAME = ?

SQL Get User Description : SELECT U_DESCRIPTION FROM USERS WHERE U_NAME = ?

SQL Get Group Description : SELECT G_DESCRIPTION FROM GROUPS WHERE G_NAME = ?

- After configuring all the above values, Need to restart the server , You should see all the users and groups based on above queries in 'myrealm' .




Below blog explains about configuring Users and Groups in Weblogic console using SQLAuthenticator


http://biemond.blogspot.com/2008/12/using-database-tables-as-authentication.html

Monday, August 26, 2013

How to invoke Stored Procedure(Pl/SQL) using ADF


This blog explains about invoking PL/SQL Stored procedure using ADF


       

    /**
     *
     * @param pDBTransaction - Instance of DBTransaction
     * @param stmt - PL/SQL Stored Procedure Name
     * @param bindVars - Array of Bind variables if needed.
     */
    public static void invokeStoredProcedure(DBTransaction pDBTransaction,
                                           String stmt, Object[] bindVars)
    {
        PreparedStatement pst = null;
        try{
            // Create Prepared statement using DBTransaction
            pst =
                pDBTransaction.createPreparedStatement("begin " + stmt + ";end;",
                                                       0);
            // Set Bind variables
            if (bindVars != null)
            {
              for (int z = 0; z < bindVars.length; z++)
              {
                pst.setObject(z + 1, bindVars[z]);
              }
            }    
            // Invoke Stored Procedure
            pst.executeUpdate();
        }catch(Exception ex){
            ex.printStackTrace();
            }finally{
            if(pst != null){
                try {
                    pst.close();
                } catch (SQLException sqle) {
                    sqle.printStackTrace();
                }
            }
            }
    }
       

- Below is sample code to invoke Stored Function

       

    /**
     * This method invokes Stored Function based on given input params
     * @param sqlReturnType
     * @param stmt
     * @param bindVars
     * @return
     */
    private Object callStoredFunction(int sqlReturnType, String storedProcedureStmt,
                                        Object[] bindVars) {
        CallableStatement st = null;
        try {
            // 1. Create a JDBC CallabledStatement
            st =
 getDBTransaction().createCallableStatement("begin ? := " + storedProcedureStmt + ";end;", 0);
            // 2. Register the first bind variable for the return value
            st.registerOutParameter(1, sqlReturnType);
            if (bindVars != null) {
                // 3. Loop over values for the bind variables passed in, if any
                for (int z = 0; z < bindVars.length; z++) {
                    // 4. Set the value of user-supplied bind vars in the stmt
                    st.setObject(z + 2, bindVars[z]);
                }
            }
            // 5. Set the value of user-supplied bind vars in the stmt
            st.executeUpdate();
            // 6. Return the value of the first bind variable
            return st.getObject(1);
        } catch (SQLException e) {
            throw new JboException(e);
        } finally {
            if (st != null) {
                try {
                    // 7. Close the statement
                    st.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public String getEmpFullName(Number n) {
        return (String)callStoredFunction(1, "get_emp_fullname(?)",
                                          new Object[] {100 });
    }
 
 // Below is Stored Function
 
 create or replace function get_emp_fullname (empid in number) return varchar2 
as
 v_full_name varchar2(120);
begin
  select first_name||' '||last_name
   into v_full_name
   from employees
   where employee_id = empid;
    
  return v_full_name;
exception
 when no_data_found then 
   return null;
end get_emp_fullname;
       
 

How to test whether Node Manager is up and running in Weblogic Console ?

This blog explains about steps to verify whether Node Manager is up and running in Weblogic console.

- Login to Weblogic console, Expand 'Environment' , select 'Machines'

- Select the 'machine' where the Node Manager installed on .


- Select 'Monitoring' tab, You should see the status as shown below.



- To Start and Stop Node Manager, Goto 'FUSION_MIDDLEWARE_HOME/wlserver_10.3/bin
   Double click on 'startNodeManager.bat' if it is in Windows.





How to create Users & Groups in Weblogic console and grant the access to users.

This blog explains about creating users and groups manually in Weblogic console,and grant the permissions to user based on their designation.

- Login to Weblogic console, Select 'Lock & Edit' , Select ' Security Realms'
- Select 'myrealms' as shown below

- Choose 'Users and Groups' tab, Select 'Users' and click on 'New' to create new user.

- Give proper name, password and click on 'Ok'

- You should see newly created user as shown below.

- Select the newly created user, Select Groups, And grant the access by shuffling the respective group from left hand side of the list to right hand side and click on 'Save' , If you want to give just monitor access, then choose 'Monitors' group .

- Select 'Release Configurations' after configuring all the users and their groups.
- All set, try logging in with newly created user login credentials.


How to configure Active Directory Users/Groups in Weblogic Server ?

Usecase : Configure LDAP Active Directory Users and Groups in weblogic console, so that all ADF applications authenticated and authorized using this.


Step1 : Login to weblogic console, select ' Security Realms', Choose 'myrealm' as shown in below screenshot.




Step2: Create a new 'Authentication provider' type of 'ActiveDirectoryAuthenticator' as shown below



Enter valid name , Select 'Type' as 'ActiveAuthenticationProvider' as shown in below screenshot.   
Step3:  Ensure to reorder newly created authentication provider to the top position in the list as shown below.



Step4: This is very very important step, Provider corresponding values for 'Provider Specific' entries for newly created 'ActiveDirectoryAuthenticator' provider as shown below.


Ensure to give correct LDAP entries for host, port, principal, credential, userBaseDN and groupBaseDN

Step5: Upon successful configuration, restart Admin server and you will see all the groups/users associated go given Principal & UserBase DN values as shown below.


Wednesday, August 21, 2013

ADF Application deployment failure with java.security.PrivilegedActionException




Error

Description: Message icon - Error An error occurred during activation of changes, please see the log for details.
Description: Message icon - Error weblogic.application.ModuleException:
Description: Message icon - Error java.security.PrivilegedActionException: weblogic.common.ResourceException: java.security.PrivilegedActionException: weblogic.common.ResourceException: No credential mapper entry found for password indirection user=apps for data source Connection1

Action Item
Right click on application -> Application properties -> Deployment -> Un check ' Auto generate ...' as shown in below screenshot.


Wednesday, August 14, 2013

How to configure Resource Bundle to Any Project in ADF



This post outlines about configuring specific Resource Bundle to configure to any project.

Right click on the project, Choose Resource Bundle, Choose Bundle Search, select the bundle which you want to configure.




Tuesday, August 13, 2013

Difference between .jsf and .jspx with 11gR1 vs 11gR2



Nice comments from Fank about usage of .jsf (Facelets) going forward with Jdeveloper 11gR2 outlined below


1. JSPX documents and Facelets are bot supported with JDeveloper 11g R2 and we do support them equallly in functionality (very little differences exist on both sides)
2. JSPX documents are the only choice in JDeveloper 11g R1
3. The future speaks Facelets (according to the JSF specification) and if you starting a new development project with JDeveloper 11g R2 then we recommend you use Facelets because of this
4. If you are on JDeveloper 11gR1, don't panic, you are good to go and we make sure your applications upgrade nicely to 11g R2 and 12c (later)
5. We plan on providing a JSPX to Facelets migration in JDeveloper. Until then, JSPX are a first class citizen as Facelets is too
6. When you are on JDeveloper 11gR1, don't wait for 12c if you need to start a development project. 

Monday, August 12, 2013

How to avoid Prompting to Save SQL Worksheet in Jdeveloper


You might have noticed with jdeveloper , whenever execute any queries in SQL Worksheet, it prompts to save sql worksheet whenever you perform 'Save All' In Jdeveloper. If you want to avoid such prompts, make below changes in your Jdeveloper

Tools-> Preferences -> Database -> Worksheet -> Un check 'Prompt for save file on close ' option.



Thursday, August 8, 2013

How to ignore unwanted files while checking into SVN Repository?


If you want to ignore some sort of files for eg : .class files while you are checking source code into SVN repository, Follow below steps


Download and install 'Tortoise SVN' client on your machine, this is one of the best IDE client to connect to SVN Repository.

Step1 : After installation, Right click on the application where you want to configure ignore list,Choose TortoiseSVN->Properties-> Click on 'New' button as shown in below screenshot.

Step2: Chohose 'svn:ignore' option from the drop down list of values, enter all the property values which you want to ignore while you are checking into SVN Repository.
Step3 : Click on 'Ok', Ensure to commit these properties into repository, So that you don't need to configure these properties every time.
                                              OR

Step4: Right click anywhere , Select Tortoise SVN -> Settings , Enter below values for 'Global Ignore Pattern' field

classes */classes output */output *. *-oc4j-app.xml *.log* *.bak *.cdi *.client_contrib *.contrib* *.generated.java *.ignore *.keep *.labellog.emd *.mv* *.rename.* *.rvi *.saved.* *.scc *.sync.* *.unbranch.* *.unco.* *.unmkelem.* .#* .*.cs .ade_path .depprod .depprod_nt .fullsource .fullsource_nt temp external_jars */external_jars deploy */deploy


Note : Tortoise SVN can ignore only Unversioned files..