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;


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);
            java.sql.Date creationDate = 
                new java.sql.Date(System.currentTimeMillis());
            stmt.setDate(1, creationDate); //Creation date
            stmt.setInt(2, getOADBTransaction().getUserId()); // Created by
            stmt.setDate(3, creationDate); //Last update date
            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());
                dtformatter.format(ConvStringDate);
            }
            stmt.setDate(6, ConvStringDate);
        } catch (Exception e) {
            throw new OAException("Exception" + e);
        }
    }

Thanks,
--Anil

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.

Thanks,
Anil

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


Steps
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 = 
            pageContext.getApplicationModule(webBean);

        // Executing KFF VO query
        oaapplicationmodule.invokeMethod("executeQuery");
                //Getting the KFF Bean 
                OAKeyFlexBean kffId = 
            (OAKeyFlexBean)webBean.findChildRecursive("kffFlex");


        kffId = (OAKeyFlexBean)webBean.findChildRecursive("kffFlex");
        kffId.setStructureCode("JOB_FLEXFIELD");
        kffId.setCCIDAttributeName("IdFlexNum");
        //kffId.setDynamicInsertion(true);
        kffId.useCodeCombinationLOV(false);

        kffId.processFlex(pageContext);
        
        System.out.println("kff " + 
                           kffId.getIndexedChildCount(pageContext.getRenderingContext()));
        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()))
                    ((OAMessageTextInputBean)uinode).setText("HYLEX");
                System.out.println(uinode.getID());
            }

        }

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