Anil's Blog is Best Viewed on GOOGLE CHROME

Please contact us for Off-shore projects, Online Trainings and any kind of Operational & Support issues

Sunday, July 20, 2014

Setting WHO columns in OAF & setting date in custom table

import java.text.SimpleDateFormat;
import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Timestamp;

Application Module Code

    public void SettingWhoColumns(String CStringDate) {
        java.sql.Date ConvStringDate = null;
        try {
            Connection conn = getOADBTransaction().getJdbcConnection();

            String Query = 
                "insert into XX_INSERT_WHO_COLUMNS  CREATION_DATE, CREATED_BY, LAST_UPDATE_DATE, LAST_UPDATED_BY, LAST_UPDATE_LOGIN) values (:1, :2, :3, :4 ,:5)";
            PreparedStatement stmt = conn.prepareStatement(Query);
            //Creation Date
            stmt.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
            stmt.setInt(2, getOADBTransaction().getUserId()); // Created by
            //Last update date 
            stmt.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
            stmt.setInt(4, getOADBTransaction().getUserId()); // Last updated by
            stmt.setInt(5,getOADBTransaction().getLoginId()); // Last updated login
            //Who columns setting end here.....

            // Getting Date as a String, Converting it to Date format and setting it
            if (CStringDate != null & !("".equalsIgnoreCase(CStringDate))) {
                SimpleDateFormat dtformatter = 
                    new SimpleDateFormat("dd-MMM-yyyy");
                ConvStringDate = 
                        new java.sql.Date(dtformatter.parse(CStringDate).getTime());
            stmt.setDate(6, ConvStringDate);
        } catch (Exception e) {
            throw new OAException("Exception" + e);


Friday, April 25, 2014

Make OAF page readonly

In the Controller process request method just write the below code to make whole page read only in one go.

import com.oaframework.toolkit.util.WebBeanUtil;

    public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
        super.processRequest(pageContext, webBean);
     // this class loops all the webbean hierarchy and make read only each and even bean and also sets the CSS accordingly.

      WebBeanUtil.setViewOnlyRecursive(pageContext, webBean);

In case of you are not able to get the WebBeanUtil file then please mail me I will provide you.


Setting value in specific segment of KFF

Hi Friends,

Recently I got a request from one of my friend to check the feasibility for setting value in one specific segment of KFF.

I tried a lot and finally I was able to accomplish this. Here is the code which you all can refer if you get this similar kind of requirement.

Just mentioning the DFF link also, incase you come across similar requirement on DFF.
Setting value in specific attribute of DFF

1. I created a dummy page and add a Flex bean to it.
2. Set few property of KFF as per below screenshot
3. Attached Controller & Application Module to this page.

In this test case, I am setting the value during page load. Hence you can see I have written code in the ProcessRequest method of the Controller.

However in case you want to set the value based on any event. So you have to capture the event in ProcessFormRequest method and then redirect to same page based on any parameter - HashMap or any session value and write the code in ProcessRequest only.

This is because when I tried to set the value in PFR method then the changes are not getting displayed.

Controller Code

        public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
        super.processRequest(pageContext, webBean);

        OAApplicationModule oaapplicationmodule = 

        // Executing KFF VO query
                //Getting the KFF Bean 
                OAKeyFlexBean kffId = 

        kffId = (OAKeyFlexBean)webBean.findChildRecursive("kffFlex");

        System.out.println("kff " + 
        int i = kffId.getIndexedChildCount(pageContext.getRenderingContext());
        for (int j = 0; j < i; j++) {
            System.out.println("Inside the for loop");
            oracle.cabo.ui.UINode uinode = 
                kffId.getIndexedChild(pageContext.getRenderingContext(), j);
            if (uinode instanceof OAMessageTextInputBean) {
                System.out.println("Inside the MTI");
                // ((OAMessageTextInputBean)uinode).setText("message");
                // ((OAMessageTextInputBean)uinode).setCSSClass("OraErrorText");
                //Setting value in selected KFF Bean (It start from 0, thats why for our case it is kffFlex0)
                if ("kffFlex0".equalsIgnoreCase(uinode.getID()))


PS: Here I have not mentioned step by step process on how to create KFF.