Anil's Blog is Best Viewed on GOOGLE CHROME

Friday, April 25, 2014

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.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.