Anil's Blog is Best Viewed on GOOGLE CHROME

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.

Sunday, April 20, 2014

Create event programatically


Use this code to set event (could be FirePartialAction or FireAction) on any field.

    public void processRequest(OAPageContext pageContext, OAWebBean webBean) {

super.processRequest(pageContext, webBean);

oracle.cabo.ui.action.FireAction FireActionA = new oracle.cabo.ui.action.FireAction();
FireActionA.setEvent("RevenueEvent"); //Event Name
FireActionA.setUnvalidated(true);
revenuechk.setPrimaryClientAction(FireActionA); //revenuechk is the Id of the field

 public void processFormRequest(OAPageContext pageContext, OAWebBean webBean){

super.processFormRequest(pageContext, webBean);

if("RevenueEvent".equals(pageContext.getParameter(SOURCE_PARAM)))

{
//Event handling here
}
Thanks,
Anil